BP_REST_Groups_Endpoint:: delete_item (WP_REST_Request美元的请求)
删除一个组。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)请求的全部细节。
返回
(WP_REST_Response)| WP_Error
源
文件:bp-groups /类/ class-bp-rest-groups-endpoint.php
public function delete_item($request){//设置上下文。$request->set_param('context', 'edit');//在删除组之前获取组。$group = $this->get_group_object($request);$previous = $this->prepare_item_for_response($group, $request);//删除论坛。If (isset($request['delete_group_forum']) && true === $request['delete_group_forum']) {$forum_ids = bbp_get_group_forum_ids($group->id);Foreach ($forum_ids as $forum_id) {wp_delete_post($forum_id, true);}} if (!group_delete_group ($group->id)) {return new WP_Error('bp_rest_group_cannot_delete', __('不能删除组。', 'buddyboss'), array('status' => 500,)); } // Build the response. $response = new WP_REST_Response(); $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); /** * Fires after a group is deleted via the REST API. * * @param object $group The deleted group. * @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_groups_delete_item', $group, $response, $request ); return $response; }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |