WP rest api endpoint protection using jwt token

Once user hit the api endpoint will check the token valid or not and process the function send information to wordpress api end point with success details. function update_payment_history(WP_REST_Request $request) { if(!$request->get_header(‘authorization’)){ return new WP_Error( ‘jwt_auth_no_auth_header’, ‘Authorization header not found.’, array( ‘status’ => 403, ) ); exit; } else if($request->get_header(‘authorization’)){ $response = wp_remote_post( ‘https://example.com/wp-json/jwt- auth/v1/token/validate’, … Read more

WordPress /users/me endpoint request forbidden

The subset of data you are seeing is the publicly available author data. ie. if a user has published content on the site, their name, gravatar and description is deemed public data and available to un-authenticated requests. If you’re seeing this user data you can assume the access_token is invalid.

WP Rest API and json_decode()

wp_remote_get return array of results containing keys body, headers, response etc depending on arguments. And json_decode only accept JSON string. So correct your code in this way //return if not an error if ( ! is_wp_error( $response ) ) { //decode and return return json_decode( wp_remote_retrieve_body( $response ) ); } Ref: Return Values of wp_remote_get … Read more

Replace content via rest api only?

You can use filter for replace text in all post and all pages. add this code to theme function.php add_filter( ‘the_content’, ‘filter_content_for_replace_text’ ); function filter_content_for_replace_text($content){ $content=str_replace(“find”,”replace with”,$content); return $content; }