• HK

    (@hk1993)


    Rest API hook ‘rest_insert_post’ not returning request object

    function wp_api_add_tax($post, $request, $update = true){
         wp_mail('[email protected]','test','data'.json_encode($request).  json_encode($post));
    }
    add_action( 'rest_insert_post', 'wp_api_add_tax',10,3 );
    

    It should return entire request object in mail, But returns empty request object altho post object is coming with data

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I cannot replicate your experience.

    Please try deactivating all plugins and switching to one of the default twenty* themes. Add your wp_mail code temporarily to the theme’s functions.php. Add a post through the REST API. You should now get a normal JSON post response and receive an email with the WP_REST_Request object, provided your server’s email sending is working correctly.

    If you just need any kind of request listing for general reference, I can provide the result of my test. I output a var_dump to a file instead of JSON encoding to email, but the data is the same either way.

Viewing 1 replies (of 1 total)
  • The topic ‘Rest API hook ‘rest_insert_post’ not returning request object’ is closed to new replies.