本文整理汇总了PHP中BP_Core_User::get_active_users方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Core_User::get_active_users方法的具体用法?PHP BP_Core_User::get_active_users怎么用?PHP BP_Core_User::get_active_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Core_User
的用法示例。
在下文中一共展示了BP_Core_User::get_active_users方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_core_ajax_widget_members
function bp_core_ajax_widget_members()
{
global $bp;
check_ajax_referer('bp_core_widget_members');
switch ($_POST['filter']) {
case 'newest-members':
if (!($users = wp_cache_get('newest_users', 'bp'))) {
$users = BP_Core_User::get_newest_users($_POST['max-members'], 1);
wp_cache_set('newest_users', $users, 'bp');
}
break;
case 'recently-active-members':
if (!($users = wp_cache_get('active_users', 'bp'))) {
$users = BP_Core_User::get_active_users($_POST['max-members'], 1);
wp_cache_set('active_users', $users, 'bp');
}
break;
case 'popular-members':
if (!($users = wp_cache_get('popular_users', 'bp'))) {
$users = BP_Core_User::get_popular_users($_POST['max-members'], 1);
wp_cache_set('popular_users', $users, 'bp');
}
break;
}
if ($users['users']) {
echo '0[[SPLIT]]';
// return valid result.
foreach ((array) $users['users'] as $user) {
?>
<li class="vcard">
<div class="item-avatar">
<a href="<?php
echo bp_core_get_userlink($user->user_id, false, true);
?>
"><?php
echo bp_core_get_avatar($user->user_id, 1);
?>
</a>
</div>
<div class="item">
<div class="item-title"><?php
echo bp_core_get_userlink($user->user_id);
?>
</div>
<div class="item-meta">
<span class="activity">
<?php
if ('newest-members' == $_POST['filter']) {
echo bp_core_get_last_activity($user->user_registered, __('registered %s ago', 'buddypress'));
} else {
if ('recently-active-members' == $_POST['filter']) {
echo bp_core_get_last_activity(get_usermeta($user->user_id, 'last_activity'), __('active %s ago', 'buddypress'));
} else {
if ('popular-members' == $_POST['filter']) {
if (1 == get_usermeta($user->user_id, 'total_friend_count')) {
echo get_usermeta($user->user_id, 'total_friend_count') . __(' friend', 'buddypress');
} else {
echo get_usermeta($user->user_id, 'total_friend_count') . __(' friends', 'buddypress');
}
}
}
}
?>
</span>
</div>
</div>
</li>
<?php
}
} else {
echo "-1[[SPLIT]]<li>" . __("No members matched the current filter.", 'buddypress');
}
}
示例2: bp_core_members_template
function bp_core_members_template($type, $per_page, $max)
{
global $bp, $bp_the_member_query;
$this->pag_page = isset($_REQUEST['upage']) ? intval($_REQUEST['upage']) : 1;
$this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
if (isset($_REQUEST['s']) && '' != $_REQUEST['s'] && $type != 'random') {
$this->members = BP_Core_User::search_users($_REQUEST['s'], $this->pag_num, $this->pag_page);
} else {
if (isset($_REQUEST['letter']) && '' != $_REQUEST['letter']) {
$this->members = BP_Core_User::get_users_by_letter($_REQUEST['letter'], $this->pag_num, $this->pag_page);
} else {
switch ($type) {
case 'random':
$this->members = BP_Core_User::get_random_users($this->pag_num, $this->pag_page);
break;
case 'newest':
$this->members = BP_Core_User::get_newest_users($this->pag_num, $this->pag_page);
break;
case 'popular':
$this->members = BP_Core_User::get_popular_users($this->pag_num, $this->pag_page);
break;
case 'online':
$this->members = BP_Core_User::get_online_users($this->pag_num, $this->pag_page);
break;
case 'alphabetical':
$this->members = BP_Core_User::get_alphabetical_users($this->pag_num, $this->pag_page);
break;
case 'active':
default:
$this->members = BP_Core_User::get_active_users($this->pag_num, $this->pag_page);
break;
}
}
}
if (!$max) {
$this->total_member_count = (int) $this->members['total'];
} else {
$this->total_member_count = (int) $max;
}
$this->members = $this->members['users'];
if ($max) {
if ($max >= count($this->members)) {
$this->member_count = count($this->members);
} else {
$this->member_count = (int) $max;
}
} else {
$this->member_count = count($this->members);
}
$this->pag_links = paginate_links(array('base' => add_query_arg('upage', '%#%'), 'format' => '', 'total' => ceil((int) $this->total_member_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1));
}
示例3: search_users
function search_users($search_terms, $limit = null, $page = 1)
{
global $wpdb, $bp;
if (!function_exists('xprofile_install')) {
return BP_Core_User::get_active_users($limit, $page);
}
if ($limit && $page) {
$pag_sql = $wpdb->prepare(" LIMIT %d, %d", intval(($page - 1) * $limit), intval($limit));
}
like_escape($search_terms);
$total_users_sql = apply_filters('bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC", $search_terms);
$paged_users_sql = apply_filters('bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql);
$total_users = $wpdb->get_var($total_users_sql);
$paged_users = $wpdb->get_results($paged_users_sql);
return array('users' => $paged_users, 'total' => $total_users);
}