3

First off.. (This info is for other readers who don't know yet about this.) There are two ways of how you can authenticate your REST API request: Using the standard cookie authentication Using a plugin like Application Passwords You can read more on the official REST API Handbook here, and this answer is for the standard cookie authentication, where the ...


2

First, nonce for an action is the same when the user is not authenticated/logged-in. (because the user ID is always 0) Secondly, you're getting false because you didn't specify the nonce action which is wp_rest in your case: // Correct usage - a valid action name is set (wp_rest). wp_verify_nonce( $clientNonce, 'wp_rest' ); // Incorrect usage - empty ...


2

The Posts endpoint accepts a slug parameter when querying for posts, so if you can get the slug from the URL, then you can make request to /wp-json/wp/v2/posts?slug=<slug>. So if the URL is http://example.com/hello-world/ and you know the slug is hello-world, then for example in JavaScript, you can do something like: fetch( 'http://example.com/wp-...


2

For remote apps (cURL, Postman, etc.), or when not using the browser, you should use an authentication plugin like Application Passwords instead of sending the cookies. But if you'd rather send the cookies, then copy and send the WordPress logged-in cookie named wordpress_logged_in_<hash>. Example in cURL: curl -H "X-WP-Nonce: <nonce>" -X POST ...


1

You can as suggested in one of the comments add &filter[posts_per_page]=250 but that is a pretty big response that may not be handled very well at either end. Maybe a better approach as suggested under pagination is to add ?per_page=100 on the first request and then make a few additional requests with ?per_page=1&page=2 etc. If you find that 100 at ...


1

The REST API supports grabbing a maximum of 100 posts at a time, so you'll have to make an additional call for every 100. Start with wp_remote_get() for 100 posts. While you're at it, go ahead and retrieve the body of this page and decode it: $transcripts = wp_remote_get('http://example.com/wp-json/wp/v2/transcript/?per_page=100'); $transcriptsBody = ...


1

The nonce authentication method is only for requests made from within WordPress, as described in your own link (emphasis mine): It is important to keep in mind that this authentication method relies on WordPress cookies. As a result this method is only applicable when the REST API is used inside of WordPress and the current user is logged in. In ...


1

define('API_ENDPOINT_VERSION', 1); //flush the rewrite rules on plugin activation function apiendpoint_activate() { flush_rewrite_rules(); } register_activation_hook(__FILE__, 'apiendpoint_activate'); function apiendpoint_register_endpoints() { register_rest_route( 'api/v1', '/post', [ 'methods' => 'GET', ...


1

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,'...


1

The problem is with your POST request, where the content property should be a plain string and not an object. You should also send just the data that you want to change. When updating a Page (i.e. a post of the type page), you should provide a JSON-encoded or URL-encoded string containing one or more of the properties/parameters as listed here. Examples ...


1

Add a third parameter in the get_post_meta() function as true, that will return the single value of the current post meta, if you don't set it it will return an array of the values. What is happening now is that internally the query is trying to compare the meta_value with an array instead of a string or integer and that's why you don't get any results. ...


1

How can i join my request and get data from multiple tables You don't, instead, you break it into multiple steps, and retrieve by individually For example, lets say I want to list the top 5 posts, and display a piece of user meta about their authors, e.g. a score. That can't be done in a single call, but that's ok, so I can instead do it in several. For ...


1

Already found, if I parse the response response.json() I get the messages in both cases


1

I was able to solve the problem by adding a custom route. Although i had to do the same process in php by first querying all available terms of the type and then exclude them from the query. $available_terms = array_map( function ( $term ) { return $term->term_id; }, get_terms( 'lagerboxen_kategorie' ) ); return get_posts( [ ...


1

Normally for checking for administration privileges you have to check the “manage_options” capability, such as: current_user_can('manage_options') Alternatively, you want to list the roles with wp_get_current_user()->roles and ensure the “Administrator” role is in that array. The capabilities you are checking for do not exist in a vanilla install of wp.


1

There's no trick. If a plugin has an API that is intended for you to use externally, such as in a React Native app, then its developer would document it. So all you can do is check if the plugin has developer documentation, and whether that documentation includes a REST API or similar. For example, WooCommerce has a REST API for some of its functionality, ...


Only top voted, non community-wiki answers of a minimum length are eligible