Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
403“;“禁止休息”;WordPress REST API中出错(但仅适用于设置)?_Wordpress_Http Status Code 403_Wordpress Rest Api - Fatal编程技术网

403“;“禁止休息”;WordPress REST API中出错(但仅适用于设置)?

403“;“禁止休息”;WordPress REST API中出错(但仅适用于设置)?,wordpress,http-status-code-403,wordpress-rest-api,Wordpress,Http Status Code 403,Wordpress Rest Api,除了设置(/wp/v2/settings),我从WordPress获得了所有API。它的返回是一个禁止的错误 { "code": "rest_forbidden", "message": "Sorry, you are not allowed to do that.", "data": { "status": 403 } } 您的用户没有访问该路由数据的正确权限。开箱即用的/settings/路由需要管理选项权限(请参阅获取项目权限检查方法) 哪个用户与API凭据关联

除了设置(/wp/v2/settings),我从WordPress获得了所有API。它的返回是一个禁止的错误

{
  "code": "rest_forbidden",
  "message": "Sorry, you are not allowed to do that.",
  "data": {
    "status": 403
  }
}

您的用户没有访问该路由数据的正确权限。开箱即用的
/settings/
路由需要
管理选项
权限(请参阅
获取项目权限检查
方法)


哪个用户与API凭据关联

设置端点需要用户具有
manage\u选项
权限;如果您使用的是自定义角色,则可以将其添加到
“管理选项”=>true


否则,只需设置用户管理员角色。

我得到了类似的结果,我可以使用带有客户端密码的应用程序API获得此结果,但在使用WP-API Basic Auth时无法获得。@calcsam-您是否能够提供此问题的更详细答案,为其他用户(包括我自己)概述您的解决方案。谢谢。Wordpress代码参考add_filter()param$priority description可能会有所帮助。请解释您的代码您正在尝试做什么。然后我会让您知道解决方案。403不允许访问,可能您的用户没有更新设置的正确权限?
// 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' );
}