REST API URL parameters not working with apache server
You’re using the wrong endpoint. Look at the documentation. id is not one of the parameters for the posts endpoint. The correct way to retrieve a post with the ID of 1 is: /wp-json/wp/v2/posts/1
You’re using the wrong endpoint. Look at the documentation. id is not one of the parameters for the posts endpoint. The correct way to retrieve a post with the ID of 1 is: /wp-json/wp/v2/posts/1
I would just hook into determine_current_user filter and check HTTP basic auth data to return the user. Maybe, just maybe, I would allow only specific user to be logged via HTTP auth. That could be done, for example, by setting an user option. The code could look like something like this (tested by OP): add_filter( … Read more
How to change user avatar using REST API?
You shouldn’t pass your nonce to your JavaScript to verify it, since client side scripts can be easily manipulated. Instead, you should get the nonce from your front-end content, and then pass it to server to verify it. After verification, you should decide to output content by server, not by your JavaScript file. Something like … Read more
No, you are not passing cookies with jQuery AJAX calls .. certainly not via Cross-domain access. If you’re going to use jQuery to pass data, you need to pass the current user ID and use get_userdata($userid) to determine whether the user has the correct capabilities. Server side: $jQuery_user = get_userdata($_POST[‘user_id’]); if(!user_can($jQuery_user,’publish_posts’)){ return array(‘reply’=>0,’error’=>’Forbidden’,’code’=>’403′); } Client … Read more
Create post using rest api with html content
We can create route using rest_api_init action like : Simply add below code to your theme functions.php file. add_action( ‘rest_api_init’, function () { register_rest_route(‘wp/v2’, ‘forgot_password’, array( ‘methods’ => array(‘GET’, ‘POST’), ‘callback’ => ‘forgot_password’ )); } ); function forgot_password(){ // YOUR CALLBACK FUNCTION STUFF HERE } forgot_password will define route URL address. methods will define which … Read more
adding this rule to .htaccess solved my problem: – RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
You didn’t include the code for your send_email() function, but I looked at the original source (revision 1) of your question, and it seems to me that your send_email() function is good, but if this answer doesn’t help solve the issue, then add the function code into your question body. So I don’t know why … Read more
To attach anything onto the results, you need to loop through each item and set the property on the object before you return it. You can do a for loop or an array_map() which essentially does a loop and sets the value for each item in the return array to what is returned by the … Read more