bp_dd_get_random_users_ids (int美元计算1字符串输出美元“数组”

获取用户id数组(或字符串)。

描述

参数

美元计算

int(可选)如果你需要全部,用0。

默认值:1

输出美元

字符串(可选)返回什么:'array'或'string'。如果字符串-逗号分隔。

默认值:“数组”

返回

(数组|字符串)默认是数组。

文件:bp-core / bp-core-tools-default-data.php

函数bp_dd_get_random_users_ids($count = 1, $output = 'array') {$users_arr = (array) bp_get_option(' bp_dd_importted_user_ids ');如果(!$total_members = count($users_arr);If ($count <= 0 || $count > $total_members) {$count = $total_members;} //获取随机用户。$random_keys = (array) array_rand($users_arr, $count);$ =用户数组();Foreach ($users_arr as $key => $value) {if (in_array($key, $random_keys)) {$users[] = $value;}}} else{//默认获取(如果没有导入用户)当前注册的所有用户。$用户= get_user(数组(“字段”= >“ID”,)); } /* * Convert to integers, because get_col() and get_users() return array of strings. */ $users = array_map( 'intval', $users ); if ( $output === 'string' ) { return implode( ',', $users ); } return $users; }

更新日志

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

问题吗?

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