仅在获取用户列表时使用WP Rest API获取管理员用户

时间:2016-05-25 10:12:10

标签: wordpress rest woocommerce woocommerce-rest-api

我正在使用带有OAuth的WordPress rest API 1.当我尝试使用wp-json / wp / v2 / users / I获取用户列表时,我只获得管理员用户详细信息,而不是所有用户。我已经完成了OAuth认证过程,获得了oauth令牌和秘密。我已经尝试过POST man以及Mozilla的REST客户端。我也得到了#34; rest_cannot_create"尝试创建任何POST或用户时。

1 个答案:

答案 0 :(得分:0)

您需要确保要显示的用户具有“list_users”功能。

// get the the role object
$role_object = get_role( $role_name );

// add $cap capability to this role object
$role_object->add_cap( $capability_name );

https://developer.wordpress.org/plugins/users/roles-and-capabilities/#adding-capabilities

相关问题