How to detect import type from All Import `pmxi_saved_post` action?

I’m writing some functions that need to perform actions on users after I import them to WordPress using the “WP All Import” plugin.

It seems that the plugin doesn’t have actions defined for each type of import (Users, Posts, Images, etc) and all imports utilize the pmxi_saved_post action to handle things that need to happen after each record is saved.

Read More

How do you determine which type of import is being performed, so as to not accidentally run actions that are supposed to be for Users (such as, sending a welcome e-mail) on Posts (which may have a colliding ID)?

Related posts

1 comment

  1. Function gets current id, so you can check it’s type with WordPress’s get_post_type($id) function.

    For example:

    add_action('pmxi_saved_post', 'pmxi_saved_post_action', 10, 1);
    function pmxi_saved_post_action($id)
    {
        $PostType = get_post_type($id);
        if($PostType=='product')
        {
    // do what you want with products for example
        }
    }
    

Comments are closed.