In wordpress whenever new blog post is created all post details need to be send to third party api. I’m using save_post hook for this but not sure whether it’s getting called or not
This is what i’ve done so far

     add_action( 'save_post', 'new_blog_details_send');
    function new_blog_details_send( $post_id ) {

  //getting blog post details//
        $blog_title = get_the_title( $post_id );
        $blog_link = get_permalink( $post_id ); 
        $blog_text = get_post_field('post_content', $post_id);

        ///Sending data to portal////
        $post_url = 'http://example.com/blog_update';
        $body = array(
                'blog_title' => $blog_title,
                'blog_link' => $blog_link,
                'blog_text' => $blog_text
        );

        //error_log($body);

        $request = new WP_Http();
        $response = $request->post( $post_url, array( 'body' => $body ) );


    }

Not sure how to log or debug in wordpress.Any help would be appericiated Thanks in advance

Read more here: save_post hook is not called when post is saved


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: