WP Rest API: Get User by Email
You can use the search argument https://example.com/wp-json/wp/v2/users/[email protected]
You can use the search argument https://example.com/wp-json/wp/v2/users/[email protected]
Excerpt from the documentation: (scroll down to the “Working With Revisions” section on that page) Note: Because the schema is stored in the user’s session cache to avoid re-fetching, you may need to open a new tab to get a new read of the Schema. So it’s probably just a caching issue and you only … Read more
I have managed to do this with hooking into rest_insert_user. I send an array like this: var data = { first_name: user.first_name, last_name: user.last_name, name: user.display_name, email: user.email, description: user.description, meta: { ‘wpcf-phone’: user.phone, ‘wpcf-institution’: user.institution, ‘wpcf-birthday’: Math.round(new Date(user.birthday).getTime()/1000) } }; And treat only the meta data through the hook as this: function aa_user_update($user, $request, … Read more
Based on the authentication documentation here – a nonce key needs to be passed with each request. So if the nonce key is being cached on the frontend beyond its lifespan, you will need to hook into the API request before the authentication step and replace the cached nonce key with a valid one. WordPress … Read more
That error could happen if wp_is_application_passwords_available() returns a false, and the docs says: By default, Application Passwords is available to all sites using SSL or to local environments. Use ‘wp_is_application_passwords_available’ to adjust its availability. So, to enable the Application Passwords: Enable SSL on your localhost, Or define WP_ENVIRONMENT_TYPE either as a global system variable or … Read more
In case anybody comes across this, I had the following in my apache config <Directory “/home/*/Sites”> AllowOverride All FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory> The WP API was trying to use the method PUT. I also believe it sometimes uses the method DELETE. Changing above code … Read more
Put this code in function.php add_action( ‘init’, ‘my_customer_cpt’ ); function my_customer_cpt() { $labels = array( ‘name’ => _x( ‘Customers’, ‘post type general name’, ‘your-plugin-textdomain’ ), ‘singular_name’ => _x( ‘Customer’, ‘post type singular name’, ‘your-plugin-textdomain’ ), ‘menu_name’ => _x( ‘Customers’, ‘admin menu’, ‘your-plugin-textdomain’ ), ‘name_admin_bar’ => _x( ‘Customer’, ‘add new on admin bar’, ‘your-plugin-textdomain’ ), ‘add_new’ … Read more
I have same problem but for auto generate time and nonce you can do this: <?php $nonce = md5(mt_rand()); // Set headers curl_setopt($ch, CURLOPT_HTTPHEADER, [‘ Authorization: OAuth oauth_consumer_key=”zfksKSt8m7Bk”, oauth_nonce=”.$nonce.”, oauth_signature=”%2BOy0fDsKilNymYOOZRqjJN5q3tg%3D”, oauth_signature_method=”HMAC-SHA1″, oauth_timestamp=’.time().’, oauth_token=”IG6x6jIjboVhmyzFtjzn1fGT”, oauth_version=”1.0″ ‘, ‘Content-Type: application/json; charset=utf-8′, ] ); I’m study for generate signature. I think It Can Be Useful To generate the signature … Read more
Keep user’s privileges on accessing contents in JSON response
WP API will ignore filter values it doesn’t understand, so the following are essentially identical: curl -gv “myamazingsite.co.uk/wp-json/wp/v2/media/?filter[id]=123” curl -gv “myamazingsite.co.uk/wp-json/wp/v2/media/” Any filter keys that are valid, however, will be used to filter the results, so if there are no images for the year 2015, the following will return nothing ([]). curl -gv “myamazingsite.co.uk/wp-json/wp/v2/media/?filter[year]=2015” I’m … Read more