我从WordPress获得了除设置(/ wp/v2/settings)之外的所有API.它返回rest_forbidden错误
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": {
"status": 403
}
}
Run Code Online (Sandbox Code Playgroud)
小智 1
您的用户没有访问该路由上的数据的正确权限。开箱即用的/settings/路线需要许可manage_options(请参阅get_item_permissions_check方法)。
// found in WP Core class-wp-rest-settings-controller.php
/**
* Checks if a given request has access to read and manage settings.
*
* @since 4.7.0
*
* @param WP_REST_Request $request Full details about the request.
* @return bool True if the request has read access for the item, otherwise false.
*/
public function get_item_permissions_check( $request ) {
return current_user_can( 'manage_options' );
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1087 次 |
| 最近记录: |