Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hello,

    It seems the Gutenberg editor is firing the publish_post hook twice because it is using rest api to update or insert the post. So if you wan to perform any tasks in the publish_post hook then you will need to check if that is rest request or not.

    add_action( 'publish_post', 'test_publish_post_hook', 10 );
    
    function test_publish_post_hook( $post_id) {
    	if ( !(defined( 'REST_REQUEST' ) && REST_REQUEST )) { 
    //your necessary executions here
    	}
    }

    Hope this helps.

    Cheers!!

Viewing 1 replies (of 1 total)