Title: endra71's Replies | WordPress.org

---

# endra71

  [  ](https://wordpress.org/support/users/endra71/)

 *   [Profile](https://wordpress.org/support/users/endra71/)
 *   [Topics Started](https://wordpress.org/support/users/endra71/topics/)
 *   [Replies Created](https://wordpress.org/support/users/endra71/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/endra71/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/endra71/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/endra71/engagements/)
 *   [Favorites](https://wordpress.org/support/users/endra71/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [publish_post hook trigger twice when I publish post](https://wordpress.org/support/topic/publish_post-hook-trigger-twice-when-i-publish-post/)
 *  [endra71](https://wordpress.org/support/users/endra71/)
 * (@endra71)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/publish_post-hook-trigger-twice-when-i-publish-post/#post-12628426)
 * 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)