December 12, 2012 at 2:21 am #11073
Is there an action that we can hook into after the initial import is done, but before Turbo CSV is done with its mojo? A new project has a requirement to delete any/all posts that are not part of the import after reach Turbo CSV import. So – it’d be a matter of checking for a specific post type and if a post ID that is part of the import is not part of the existing post IDs, then remove it. So – the action and what holds a list of imported IDs would be awesome. Really appreciate it. Thanks!December 12, 2012 at 5:24 am #11074ChrisKeymaster
From what you said, it sounds like maybe it would be easier to just delete all posts before the import?
If that won’t work though: ll the normal WordPress actions are called. The ‘save_post’ action is triggered after each post is created.
There’s also MapPress action that is called during the import:
Hopefully those actions will be helpful. If you need to access the import, you can get a list of imports like this:
$imports = TI_Import::get_list();
Get one import where $id is the import ID you want to retrieve:
$import = TI_Import::get_list();
Get import lines for the import – this returns an array of class TI_Import_Line
$lines = $Import->get_imported_posts();
You can take a look at the TI_Import_Line definition to see the fields. For example:
$lines->post_idDecember 12, 2012 at 7:49 am #11077
Appreciate the response. The data will actually be used throughout the rest of the system, so deleting all of them before-hand probably won’t be a good idea. I think that ‘mappress_update_meta’ action may be where I want to do the check.
It sounds like I could use that action to:
Grab all of the imported posts with: $lines = $Import->get_imported_posts();
Then grab all of the posts that current exist (using get_posts())
Compare the IDs in each and then use http://codex.wordpress.org/Function_Reference/wp_delete_post to remove the ones that don’t match
Does the TI_Import class also hold the template name in the event I don’t want to do this for every “type” of import? Thanks again!December 12, 2012 at 8:23 am #11078ChrisKeymaster
The TI_Import object has a ‘template’ property that contains a TI_Template object. You can see both in ‘ti_import.php’.December 12, 2012 at 8:25 am #11079
Awesome – I’ll see what I can do with this. Thanks again!
- You must be logged in to reply to this topic.