0

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

4
  • what is the exact result in the email body ? is it data[]{post datas here...} ?
    – mmm
    Commented Oct 31, 2017 at 8:28
  • @mmm Email body data{}{"ID":2733,"post_author":"1","post_date":"2017-10-31 04:26:51","........} Commented Oct 31, 2017 at 12:50
  • it looks like a bug of "json_encode" because the variable is not empty, you can see it with var_export($request, TRUE) e.g.
    – mmm
    Commented Oct 31, 2017 at 13:23
  • @mmm How we can apply this things in hook ? Commented Nov 7, 2017 at 9:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.