BP_REST_Members_Actions_Endpoint:: update_item (WP_REST_Request美元的请求

检查给定请求是否具有访问create成员的权限。

描述

参数

美元的请求

WP_REST_Request(必需)请求的全部细节。

返回

(bool | WP_Error)

文件:bp-members /类/ class-bp-rest-members-actions-endpoint.php

public function update_item($request){//设置上下文。$request->set_param('context', 'edit');$ args =阵列(' leader_id ' = > (int)美元请求(“id”),“follower_id”= > get_current_user_id ());数组$响应= ();数组$ retval = ();$响应['行动']= false;/** *过滤请求的查询参数。* * @param array $args查询变量的关键值数组。@param WP_REST_Request $request发送给API的请求。* * @since 0.1.0 */ $args = apply_filters('bp_rest_members_action_query_args', $args, $request); $action = $request['action']; switch ( $action ) { case 'follow': if ( ! $this->bp_rest_follow_is_following( $args ) ) { $result = $this->bp_rest_follow_start_following( $args ); $response['action'] = ( ! empty( $result ) ? true : false ); } break; case 'unfollow': if ( $this->bp_rest_follow_is_following( $args ) ) { $result = $this->bp_rest_follow_stop_following( $args ); $response['action'] = ( ! empty( $result ) ? true : false ); } break; } $member_query = bp_core_get_users( array( 'include' => (int) $request['id'] ) ); $members = $member_query['users']; $request->set_param( 'context', 'view' ); foreach ( $members as $member ) { $retval[] = $this->prepare_response_for_collection( $this->members_endpoint->prepare_item_for_response( $member, $request ) ); } $response['data'] = ( count( $members ) > 1 ? $retval : ( ! empty( $retval ) ? $retval[0] : '' ) ); $response = rest_ensure_response( $response ); /** * Fires after a Member action is updated via the REST API. * * @param BP_XProfile_Field $field Created field object. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_members_action_update_item', $response, $request ); return $response; }

更新日志

更新日志
版本 描述
0.1.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队