Application Password is not enable by default?

If you want to add that single filter, you can do it in your theme’s functions.php file. If you’d prefer to keep it out of the theme, you can make it a simple Must Use Plugin. Make a file like wp-content/mu-plugins/enable-application-passwords.php with this file content: <?php /** * Plugin Name: Enable Application Passwords * Description: … Read more

WordPress Rest API response

You might be able to output your headers with the response. Then just kill the request with exit();. The default is usually to return a value and let the process encode and output for you. Based on http://v2.wp-api.org/extending/adding/ function my_awesome_func( $data ) { header(“Content-Type: text/plain”); print_r( array(‘foo’=>’bar’)); exit(); } add_action( ‘rest_api_init’, function () { register_rest_route( … Read more

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

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

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

How can I return an image from a custom REST API endpoint?

echo in the rest-api and not valid! You should using return to make output to Rest API. For example: function prefix_generate_cover_photo( WP_REST_Request $request ) { // Get method params $params = $request->get_params(); // Data $data = array( ‘url’ => ‘The image url’, ‘title’ => ‘The image title’, ); // Create the response object $response = … Read more

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