gpt4 book ai didi

wordpress - WordPress REST API 中的 403 "rest_forbidden"错误(但仅限于设置)?

转载 作者:行者123 更新时间:2023-12-04 04:42:35 26 4
gpt4 key购买 nike

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

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

最佳答案

您的用户没有访问该路线数据的正确权限。开箱即用 /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' );
}

关于wordpress - WordPress REST API 中的 403 "rest_forbidden"错误(但仅限于设置)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45931189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com