Impossible to create a new WooCommerce customer using Rest API

In the documentation of WP REST User https://wordpress.org/plugins/wp-rest-user/ you have the aswer: To perform further actions after user is registered, write and add_action: add_action(‘wp_rest_user_user_register’, ‘user_registered’); function user_registered($user) { // Do Something } Replace “// Do Something” for the code to change the user role. Something like this (not tested): $u = new WP_User( 3 ); … Read more

WordPress rest API get Posts parent by post ID

As posts can’t have parents, there is no endpoint to get the parent ID of a post. However, pages can have parents, so the page endpoint should return a parent ID, among other things. So, by getting mysite.com/wp-json/wp/v2/pages, you should be able to get the parent attribute, which is “The ID for the parent of … Read more

Accessing Custom REST endpoint with rest_do_request()

I done a bit of experimenting and in my custom endpoint i replaced : wp_send_json($items); with : return new \WP_REST_Response ($items); However I do not see how to extract my data from the WP_REST_Request object. I can see it is there with var_dump. But I can find no documentation as to how to access the … Read more

Media gallery images url instead of ID on WP API

Have a look at wp_get_attachment_image_url for getting the URL of images: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url/ or wp_get_attachment_url for getting the URL for attachments other than images: https://developer.wordpress.org/reference/functions/wp_get_attachment_url/. These functions return the URLs only and you could use them like so: // your JSON $json = ‘ { “Gallery Images”: [ “1833”, “1834”, “1835” ] } ‘; // convert … Read more

Action on Custom Post publish

Issue is resolved Updated Code <?php /* Plugin Name: Send Notification CPT Description: Declares a plugin that will create a custom post type to send notifications. Version: 1.0 */ if( ! defined(‘ABSPATH’)) { exit; } // Register Custom Post Type Send Notifiction function create_sendnotifiction_cpt() { $labels = array( ‘name’ => _x( ‘Send Notifiction’, ‘Post Type … Read more

How do i post data to url with fields?

You have to build the array as the json array needs to be $args = array( ‘headers’ => array( ‘Content-Type’ => ‘application/json’, ‘Authorization’ => ‘Basic ‘.$apiKey ) ); $bdy = array( ‘fields’=> array( ‘project’ => array( ‘key’ =>’LD’ ), ‘summary’=> ‘CODING WORKS’, ‘description’ => ‘Creating of an issue using project keys and issue type names … Read more

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