WP-API / Basic-Auth

Basic Authentication handler for the JSON API, used for development and debugging purposes
761 stars 281 forks source link

WP rest api plugin Create user Error #41

Open dharmeshtops opened 7 years ago

dharmeshtops commented 7 years ago

i want to create/insert new user using rest api but i am getting this type of error. also i am using auth1.0 consumer and secret in auth1.0 method in postman. Error code: [ { "code": "json_user_cannot_list", "message": "Sorry, you are not allowed to list users." } ]

carl0s commented 7 years ago

No news about that? I have problems either

BrianHenryIE commented 7 years ago

Your question isn't related to authentication, rather authorization. You need to give the user who is making the REST call permission to both create and list users.

$user = new WP_User( $user_id );
$user->add_cap( 'create_users' );
$user->add_cap( 'list_users' );