• Resolved krystianj

    (@krystianj)


    I have custom post type with slug ‘video’ when I publish post I don’t receive webhooks.
    When I add simple post everything working great.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter krystianj

    (@krystianj)

    I write my own webhooks and now working

    @krystianj, do you mind sharing your webhook? I like to see how you went about doing that.

    Thread Starter krystianj

    (@krystianj)

    Hi,
    My resolve is

    function publish_post_hook( $post_id, $post, $update ) {
      $url = $GLOBALS['webhook_url'] . '/post';
      if ( $post->post_status === 'publish') { // Only fire when published
        $response = wp_remote_post(
          $url,
          array(
            'blocking' => true,
            'body' => array(
              'id'      => $post_id,
              'type'    => $post->post_type,
              'status'  => $post->post_status,
              )
            )
          );
      }
    }
    
    add_action( 'wp_insert_post', 'publish_post_hook', 10, 3 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post type’ is closed to new replies.