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 ) )

    if($post->post_type == "incsub_event"){
        //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) {

add_action( 'wp_insert_post', 'wemap_update_create_event', 10, 3 );
  • Have you tried something like function wemap_update_create_event( $post_id, $post, $update ) { if ( $update ) { echo 'is post update'; } else { echo 'is new post'; } } ? – Sally CJ Aug 13 at 11:52
  • Yes, the conditio is always true... – Morgan Tartreau Aug 13 at 12:01
  • Are you sure? Because I tried it (except I use error_log() and not echo) and I got the correct status - is post update if the post is being updated; is new post if the post is new. – Sally CJ Aug 13 at 13:29
  • Absolutely, I think it's strange too... That's why I'm here ^^ – Morgan Tartreau Aug 13 at 14:03
  • Well, that's indeed strange.. have you checked the plugin docs? It probably has a hook for running custom actions when an event is created.. ? – Sally CJ Aug 13 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.