How add meta fields to a user with the wp-api?

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

Application passwords not working on localhost?

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

403 Forbidden with gutenberg

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

Custom Post Type and API REST is not working

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

How to generate HMAC-SHA1 signature to use with WP REST API and OAuth1

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

WP API ignores filter parameter

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