Wordpress - REST API - How to set up roles

Wordpress REST API allows roles as array.

But when you try to set roles as it is, it throws error.

Correct list of roles:

  • administrator
  • editor
  • author
  • contributor
  • subscriber
  • customer

As you see, all of these role names must be in lower case.

For example:

$user = WordpressAPI::createUser([
'username' => 'test',
'email' => 'test@gmail.com',
'password' => '123456QQQ',
'roles' => ['subscriber'] 
]);

And you can add your own roles that you created in system.

Comments

Popular posts from this blog

Idea PhpStorm - How to fix bugs with incorrect code Inspections and Autocomplete

CSS Как прикрепить слой (div) к краю

PHP - How to show expected return array elements