BP_REST_Groups_Endpoint:: bp_rest_get_sub_groups (整数parent_group_id美元)
获取子组id。
描述
参数
- parent_group_id美元
-
(整数)(必需)组ID。
返回
(数组)
源
文件:bp-groups /类/ class-bp-rest-groups-endpoint.php
Public function bp_rest_get_sub_groups($parent_group_id) {if (empty($parent_group_id)) {return array();} $user_id = bp_loggedin_user_id();$filter = (false !== $user_id && !)Bp_user_can ($user_id, 'bp_moderate'));If (function_exists('bp_include_group_by_context ')) {$sub_groups = group_get_groups (array('parent_id' => $parent_group_id, 'fields' => 'ids', 'show_hidden' => true, 'per_page' => false, 'page' => false,));//重置父数组,为下一轮重建。$组=数组();Foreach ($sub_groups['groups'] as $group) {if ($filter) {if (bp_include_group_by_context($group, $user_id, 'normal')) {$groups[] = $group->id;}} else {$groups[] = $group->id;}}返回$groups; // buddypress support. } else { $sub_groups = groups_get_groups( array( 'parent_id' => $parent_group_id, 'fields' => 'ids', 'show_hidden' => false, 'per_page' => false, 'page' => false, ) ); if ( ! empty( $sub_groups ) && isset( $sub_groups['groups'] ) && ! empty( $sub_groups['groups'] ) ) { return $sub_groups['groups']; } } return array(); }