BP_Groups_Member:: get_user_memberships (intuser_id美元数组args美元数组()

获取用于个人数据导出的用户成员资格。

描述

参数

user_id美元

int(必需)用户ID。

args美元

数组(可选)可选参数数组。

  • “页面”
    (int)正在请求的会员页。默认的1。
  • “per_page”
    (int)会员返回每页。默认的20。
  • “类型”
    (字符串)正在请求的成员类型。接受'membership', 'pending_request', 'pending_received_invitation', 'pending_sent_invitation'。默认的“会员”。

默认值:数组()

返回

(数组)

文件:bp-groups /类/ class-bp-groups-member.php

Public static function get_user_memberships($user_id, $args = array()) {global $wpdb;英国石油美元= buddypress ();$ r = array_merge(阵列(“页面”= > 1,' per_page ' = > 20,“类型”= >“会员”,),美元args);$ sql =阵列('选择' = > ' select * ',”从“= >”{$ bp - >组> table_name_members}”,的地方 ' => '', ' 限制 ' => '', );Switch ($r['type']) {case 'pending_request': return group_get_requests (array('user_id' => $user_id, 'page' => $r['page'], 'per_page' => $r['per_page'],));打破;Case 'pending_received_invitation': return groups_get_invitation (array('user_id' => $user_id, 'page' => $r['page'], 'per_page' => $r['per_page'],));打破;Case 'pending_sent_invitation': return groups_get_invitation (array('inviter_id' => $user_id, 'page' => $r['page'], 'per_page' => $r['per_page'],));打破; case 'membership' : default : $sql['where'] = $wpdb->prepare( "user_id = %d AND is_confirmed = 1", $user_id ); break; } if ( $r['page'] && $r['per_page'] ) { $sql['limits'] = $wpdb->prepare( "LIMIT %d, %d", ( $r['page'] - 1 ) * $r['per_page'], $r['per_page'] ); } $memberships = $wpdb->get_results( "{$sql['select']} {$sql['from']} WHERE {$sql['where']} {$sql['limits']}" ); foreach ( $memberships as &$membership ) { $membership->id = (int) $membership->id; $membership->group_id = (int) $membership->group_id; $membership->user_id = (int) $membership->user_id; $membership->inviter_id = (int) $membership->inviter_id; $membership->is_admin = (int) $membership->is_admin; $membership->is_mod = (int) $membership->is_mod; $membership->is_banned = (int) $membership->is_banned; $membership->is_confirmed = (int) $membership->is_confirmed; $membership->invite_sent = (int) $membership->invite_sent; } return $memberships; }

更新日志

更新日志
版本 描述
BuddyPress 4.0.0 BuddyPress 4.0.0
BuddyBoss 1.3.5 介绍了。

问题吗?

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