BP_REST_Document_Folder_Endpoint:: create_item_permissions_check (WP_REST_Request美元的请求)
检查给定请求是否具有创建文件夹的访问权限。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)关于请求的完整数据。
返回
(WP_Error | bool)
源
文件:bp-document /类/ class-bp-rest-document-folder-endpoint.php
Public function create_item_permissions_check($request) {$retval = true;如果(!is_user_logged_in()) {$retval = new WP_Error('bp_rest_authorization_required', __('对不起,您不允许创建一个文件夹。', 'buddyboss'), array('status' => rest_authorization_required_code(),));}如果真的= = = retval & &收取美元($请求[' group_id ']) & & !Empty ($request['group_id']) {if (!bp_is_active('groups') || group_can_user_manage_document (bp_loggedin_user_id(), (int) $request['group_id'])) {$retval = new WP_Error('bp_rest_invalid_permission', __('You don 't have a permission to create a folder in this group '), __('You don 't have a permission to create a folder in this group ');', 'buddyboss'), array('status' => rest_authorization_required_code(),));}}如果真的= = = retval & &收取美元($请求(“母公司”))& & !$request['parent'] = new BP_Document_Folder($request['parent']);if (empty($parent_folder->id)) {$retval = new WP_Error('bp_rest_invalid_parent_folder', __('无效的父文件夹id。', 'buddyboss'), array('status' => 400,));} elseif (! bp_folder_user_can_edit( $parent_folder->id ) ) { $retval = new WP_Error( 'bp_rest_invalid_permission', __( 'You don\'t have a permission to create a folder inside this folder.', 'buddyboss' ), array( 'status' => rest_authorization_required_code(), ) ); } } /** * Filter the document folder `create_item` permissions check. * * @param bool|WP_Error $retval Returned value. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ return apply_filters( 'bp_rest_document_folder_create_items_permissions_check', $retval, $request ); }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |