当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_Core_User::get_random_users方法代码示例

本文整理汇总了PHP中BP_Core_User::get_random_users方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Core_User::get_random_users方法的具体用法?PHP BP_Core_User::get_random_users怎么用?PHP BP_Core_User::get_random_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Core_User的用法示例。


在下文中一共展示了BP_Core_User::get_random_users方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_core_get_random_member

/**
 * bp_core_get_random_member()
 *
 * Returns the user_id for a user based on their username.
 * 
 * @package BuddyPress Core
 * @param $username str Username to check.
 * @global $wpdb WordPress DB access object.
 * @return false on no match
 * @return int the user ID of the matched user.
 */
function bp_core_get_random_member()
{
    global $bp, $wpdb;
    if ($bp->current_component == BP_MEMBERS_SLUG && isset($_GET['random'])) {
        $user = BP_Core_User::get_random_users(1);
        $ud = get_userdata($user['users'][0]->user_id);
        bp_core_redirect($bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login);
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:20,代码来源:bp-core.php

示例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));
 }
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:51,代码来源:bp-core-templatetags.php

示例3: bp_friends_random_members

function bp_friends_random_members($total_members = 5)
{
    global $bp;
    if (!($user_ids = wp_cache_get('friends_random_users', 'bp'))) {
        $user_ids = BP_Core_User::get_random_users($total_members);
        wp_cache_set('friends_random_users', $user_ids, 'bp');
    }
    ?>
	
	<?php 
    if ($user_ids['users']) {
        ?>
		<ul class="item-list" id="random-members-list">
		<?php 
        for ($i = 0; $i < count($user_ids['users']); $i++) {
            ?>
			<li>
				<a href="<?php 
            echo bp_core_get_userurl($user_ids['users'][$i]->user_id);
            ?>
"><?php 
            echo bp_core_get_avatar($user_ids['users'][$i]->user_id, 1);
            ?>
</a>
				<h5><?php 
            echo bp_core_get_userlink($user_ids['users'][$i]->user_id);
            ?>
</h5>
				<?php 
            if (function_exists('xprofile_get_random_profile_data')) {
                ?>
					<?php 
                $random_data = xprofile_get_random_profile_data($user_ids['users'][$i]->user_id, true);
                ?>
					<div class="profile-data">
						<p class="field-name"><?php 
                echo $random_data[0]->name;
                ?>
</p>
						<?php 
                echo $random_data[0]->value;
                ?>
					</div>
				<?php 
            }
            ?>
				
				<div class="action">
					<?php 
            if (function_exists('bp_add_friend_button')) {
                ?>
						<?php 
                bp_add_friend_button($user_ids['users'][$i]->user_id);
                ?>
					<?php 
            }
            ?>
				</div>
			</li>
		<?php 
        }
        ?>
		</ul>
	<?php 
    } else {
        ?>
		<div id="message" class="info">
			<p><?php 
        _e("There aren't enough site members to show a random sample just yet.", 'buddypress');
        ?>
</p>
		</div>		
	<?php 
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:75,代码来源:bp-friends-templatetags.php


注:本文中的BP_Core_User::get_random_users方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。