rest Api jwt authentication for get methodes

The token just authenticates the request as coming from a specific user. You still need to use the permissions callback to check if that user has permission for whatever it is you’re doing. If you omit the permissions_callback argument when registering the route then the route is public. If you only need to check if … Read more

WC_Customer delete function returns error

Welcome! You need to include ‘wp-admin/includes/user.php’ before calling wp_delete_user function. The reason is, it is an admin functionality and it is not available everywhere in code. In Your case, just put the following line of code at the very beginning of the function. require_once ABSPATH . ‘wp-admin/includes/user.php’;

Custom API plugin to execute 3rd party API to retrieve data

If you need to pass username and password for Basic Auth you need to send that in headers e.g. $headers = array(‘Authorization’ => ‘Basic ‘ . base64_encode( YOUR_USERNAME . ‘:’ . YOUR_PASSWORD ); $response = wp_remote_post( $url, array( ‘method’ => ‘POST’, ‘timeout’ => 45, ‘headers’ => $headers ) ); If you need to pass username … Read more

How to integrate together a website currently hosted WordPress.com and a custom web application currently hosted on Azure?

To handle the single domain, you’ll want to obtain hosting that will run both your currently Azure-hosted site and WordPress. Usually Linux is the easiest way to go, though WP can run on IIS. You basically need to migrate the existing Azure-hosted site. Then, you can install WordPress in either a subdomain or a subfolder. … Read more

Accessing private posts through REST API, same code that works in remote doesn’t in local

The problem was that I didn’t completely clone the wp site, and I forgot to install the plugin that I used to manage user roles The plugin is Members (“User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress”) by MemberPress, and there I can allow the roles that I … Read more

Backbone with custom rest endpoints

From the documentation: Backbone.sync is the function that Backbone calls every time it attempts to read or save a model to the server. By default, it uses jQuery.ajax to make a RESTful JSON request and returns a jqXHR. The sync function may be overridden globally as Backbone.sync, or at a finer-grained level, by adding a sync function to a Backbone collection or to an … Read more

How to send the body in wp_remote_post as “raw”?

I got this one working, you have to pass the json_encoded array on the body parameter of the request. $customer_details = [ ‘first_name’ => $first_name, ‘last_name’ => $last_name, ’email’ => $email, ]; $customer_details[‘body’] = json_encode($customer_details); $customer = $api->createUpdateCustomer($customer_details); public function createUpdateCustomer($customer_details) { $response = $this->apiCall( “2.0/customers”, ‘POST’, $customer_details); $result = json_decode($response); return $result; } public … Read more