Rest API redirection update status disabled not working
-
Hi,
I’ve been trying to interface with the Rest API, my scenario is that I am creating a new redirection item for a new post when its created, the target url will be the permalink of this new post.
My issue is when I trash the post, I expect it to change the status of the redirection to ‘disabled’, but it does not seem to work, only the target url get’s updated, here’s a screenshot:
The parameters I pass is this:
I am using the action:
add_action( 'transition_post_status', 'createRedirect', 10, 3 );
And in the function:
... // When trashed elseif ( ( $new == 'trash' ) && ( $old == 'publish' ) ) : //wp_die(var_dump($new) . var_dump($old)); $redirectSlugID = get_field('redirect_id', $post->ID); $params['url'] = get_field('short_url_slug', $post->ID); $params['status'] = "disabled"; //wp_die(var_dump($params)); $request = new WP_REST_Request( 'POST', '/redirection/v1/redirect/' . $redirectSlugID); $request->set_query_params( $params ); $response = rest_do_request( $request ); else : return; endif; ...
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Rest API redirection update status disabled not working’ is closed to new replies.