Why the Path is different with the one coded in rest

No it shouldn’t. The first parameter is called namespace. It’s like the scope for your functions such as this: function my_function(){ $data = 0; } You can only use $data inside that function. Same goes with the REST endpoints. The path /test/ will be available only under its specific namespace. You should choose a unique … Read more

How to use REST API to send user metadata?

I’m not a WP API expert. It sounds like you want to store more information than the API supports, so you will need to add an endpoint – https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/ If you are doing payment processing, I assume you are using a service or plugin + service for that, so you may want your custom endpoints … Read more

How to add / embed an author into REST data from a custom post type?

I found out how to grab each result and add a link. For the ananda_video_audio post type: add_filter( ‘rest_prepare_ananda_video_audio’, function( $results ) { // These two lines are unique to our code of course $video = new Ananda_Video_Audio( $results->data[‘id’] ); $authors = $video->get_author_IDs(); foreach( $authors as $author_id ) { $results->add_link( ‘author’, rest_url( ‘/wp/v2/users/’ . $author_id … Read more

Make authorization mandatory on custom routes

Late, but maybe helpful for other readers as I added solution specifically to above code of this question. Solution: Permission Callback function WordPress: version 5.7.2 PHP: version 7.4 host: hostmonster.com client: Windows 10 browsers: tested on Chrome, Firefox, even Edge 😜 worked Code (PHP code in function.php of your installed theme): add_action(‘rest_api_init’, function() { /** … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)