admin管理员组

文章数量:1416333

I'm creating an Event thanks to a plugin (Event plus).

I need to alter the hook when the event is created, I tried with the native WP functions, but as WP (or the plugin ?) always create an ID for the post type (to save the draft automaticaly), the "updated" is always trigger.

I need to do some function if the event is a new, and some function if the event is an existing one. What should I change ?

    function wemap_update_create_event( $post_id, $post, $update ) {

    if ( wp_is_post_revision( $post_id ) )
        return;

    if($post->post_type == "incsub_event"){
        nice($post);
        //check if the post is in the database or not with get_post( $post_id ) == null
        if( get_post( $post_id ) == null ) {
            die("not in db");
        }
        if($update && get_post( $post_id ) != null) {

            die("update");
        }
    }
}
add_action( 'wp_insert_post', 'wemap_update_create_event', 10, 3 );

本文标签: Hook createupdate post