BP_Groups_Member:: get_group_ids (intuser_id美元,int | bool美元的限制=假,int | bool美元的页面=假)
获取指定用户所属的组的id。
描述
参数
- user_id美元
-
(int)(必需)用户ID。
- 美元的限制
-
(int|保龄球)(可选)返回的最大结果数。默认值:false(无限制)。
默认值:假
- 美元的页面
-
(int|保龄球)(可选)返回结果的页偏移量。默认值:false(无限制)。
默认值:假
返回
(数组)
- “组织”
(数组)分页查询返回的组数组。 - “总”
(int)匹配查询的组计数。
源
文件:bp-groups /类/ class-bp-groups-member.php
Public static function get_group_ids($user_id, $limit = false, $page = false) {global $wpdb;$ pag_sql =”;$pag_sql = $wpdb->prepare(" limit %d, %d", intval(($page - 1) * $limit), intval($limit));英国石油美元= buddypress ();//如果用户登录并查看自己的组,我们可以显示隐藏组和私有组。if ($user_id != bp_loggedin_user_id()) {$ group_sql = $wpdb->prepare("SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0{$pag_sql}", $user_id);$total_groups = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id);} else {$ group_sql = $wpdb->prepare("SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0{$pag_sql}", $user_id);$total_groups = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_ban = 0", $user_id));} $groups = $wpdb->get_col($group_sql); return array( 'groups' => $groups, 'total' => (int) $total_groups ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.6.0 | 介绍了。 |