本文整理匯總了PHP中BP_Core_User::get_users方法的典型用法代碼示例。如果您正苦於以下問題:PHP BP_Core_User::get_users方法的具體用法?PHP BP_Core_User::get_users怎麽用?PHP BP_Core_User::get_users使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BP_Core_User
的用法示例。
在下文中一共展示了BP_Core_User::get_users方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bp_core_get_users
/**
* Return an array of users IDs based on the parameters passed.
*
* @package BuddyPress Core
*/
function bp_core_get_users($args = '')
{
$defaults = array('type' => 'active', 'user_id' => false, 'exclude' => false, 'search_terms' => false, 'meta_key' => false, 'meta_value' => false, 'include' => false, 'per_page' => 20, 'page' => 1, 'populate_extras' => true);
$params = wp_parse_args($args, $defaults);
extract($params, EXTR_SKIP);
return apply_filters('bp_core_get_users', BP_Core_User::get_users($type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras, $exclude, $meta_key, $meta_value), $params);
}
示例2: test_type_alphabetical
/**
* @expectedDeprecated BP_Core_User::get_users
* @group get_users
* @group type
*/
public function test_type_alphabetical()
{
$u1 = $this->factory->user->create(array('display_name' => 'foo'));
$u2 = $this->factory->user->create(array('display_name' => 'bar'));
global $wpdb;
$q = BP_Core_User::get_users('alphabetical');
$found = array_map('intval', wp_list_pluck($q['users'], 'id'));
$this->assertEquals(array($u2, $u1), $found);
}
示例3: bp_core_get_users
/**
* Return an array of users IDs based on the parameters passed.
*
* Since BuddyPress 1.7, bp_core_get_users() uses BP_User_Query. If you
* need backward compatibility with BP_Core_User::get_users(), filter the
* bp_use_legacy_user_query value, returning true.
*
* @package BuddyPress Core
*/
function bp_core_get_users($args = '')
{
// Parse the user query arguments
$params = wp_parse_args($args, array('type' => 'active', 'user_id' => false, 'exclude' => false, 'search_terms' => false, 'meta_key' => false, 'meta_value' => false, 'include' => false, 'per_page' => 20, 'page' => 1, 'populate_extras' => true, 'count_total' => 'count_query'));
// For legacy users. Use of BP_Core_User::get_users() is deprecated.
if (apply_filters('bp_use_legacy_user_query', false, __FUNCTION__, $params)) {
extract($params, EXTR_SKIP);
$retval = BP_Core_User::get_users($type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras, $exclude, $meta_key, $meta_value);
// Default behavior as of BuddyPress 1.7
} else {
// Get users like we were asked to do...
$users = new BP_User_Query($params);
// ...but reformat the results to match bp_core_get_users() behavior.
$retval = array('users' => array_values($users->results), 'total' => $users->total_users);
}
return apply_filters('bp_core_get_users', $retval, $params);
}
示例4: 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_users( 'random', $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_user_domain( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->user_id, 'type' => 'thumb' ) ) ?></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 } ?>
<?php
}
示例5: bp_core_get_users
/**
* Fetch an array of users based on the parameters passed.
*
* Since BuddyPress 1.7, bp_core_get_users() uses BP_User_Query. If you
* need backward compatibility with BP_Core_User::get_users(), filter the
* bp_use_legacy_user_query value, returning true.
*
* @since 1.2.0
*
* @param array|string $args {
* Array of arguments. All are optional. See {@link BP_User_Query} for
* a more complete description of arguments.
* @type string $type Sort order. Default: 'active'.
* @type int $user_id Limit results to friends of a user. Default: false.
* @type mixed $exclude IDs to exclude from results. Default: false.
* @type string $search_terms Limit to users matching search terms. Default: false.
* @type string $meta_key Limit to users with a meta_key. Default: false.
* @type string $meta_value Limit to users with a meta_value (with meta_key). Default: false.
* @type array|string $member_type Array or comma-separated string of member types.
* @type array|string $member_type__in Array or comma-separated string of member types.
* `$member_type` takes precedence over this parameter.
* @type array|string $member_type__not_in Array or comma-separated string of member types to be excluded.
* @type mixed $include Limit results by user IDs. Default: false.
* @type int $per_page Results per page. Default: 20.
* @type int $page Page of results. Default: 1.
* @type bool $populate_extras Fetch optional extras. Default: true.
* @type string|bool $count_total How to do total user count. Default: 'count_query'.
* }
* @return array
*/
function bp_core_get_users($args = '')
{
// Parse the user query arguments.
$r = bp_parse_args($args, array('type' => 'active', 'user_id' => false, 'exclude' => false, 'search_terms' => false, 'meta_key' => false, 'meta_value' => false, 'member_type' => '', 'member_type__in' => '', 'member_type__not_in' => '', 'include' => false, 'per_page' => 20, 'page' => 1, 'populate_extras' => true, 'count_total' => 'count_query'), 'core_get_users');
// For legacy users. Use of BP_Core_User::get_users() is deprecated.
if (apply_filters('bp_use_legacy_user_query', false, __FUNCTION__, $r)) {
$retval = BP_Core_User::get_users($r['type'], $r['per_page'], $r['page'], $r['user_id'], $r['include'], $r['search_terms'], $r['populate_extras'], $r['exclude'], $r['meta_key'], $r['meta_value']);
// Default behavior as of BuddyPress 1.7.0.
} else {
// Get users like we were asked to do...
$users = new BP_User_Query($r);
// ...but reformat the results to match bp_core_get_users() behavior.
$retval = array('users' => array_values($users->results), 'total' => $users->total_users);
}
/**
* Filters the results of the user query.
*
* @since 1.2.0
*
* @param array $retval Array of users for the current query.
* @param array $r Array of parsed query arguments.
*/
return apply_filters('bp_core_get_users', $retval, $r);
}
示例6: friends_get_newest
/**
* Get a user's friends, in the order in which they joined the site.
*
* @see BP_Core_User::get_users() for a description of return value.
*
* @param int $user_id ID of the user whose friends are being retreived.
* @param int $per_page Optional. Number of results to return per page.
* Default: 0 (no pagination; show all results).
* @param int $page Optional. Number of the page of results to return.
* Default: 0 (no pagination; show all results).
* @param string $filter Optional. Limit results to those matching a search
* string.
* @return array See {@link BP_Core_User::get_users()}.
*/
function friends_get_newest($user_id, $per_page = 0, $page = 0, $filter = '')
{
return apply_filters('friends_get_newest', BP_Core_User::get_users('newest', $per_page, $page, $user_id, $filter));
}
示例7: friends_get_newest
/**
* Get a user's friends, in the order in which they joined the site.
*
* @since 1.0.0
*
* @see BP_Core_User::get_users() for a description of return value.
*
* @param int $user_id ID of the user whose friends are being retrieved.
* @param int $per_page Optional. Number of results to return per page.
* Default: 0 (no pagination; show all results).
* @param int $page Optional. Number of the page of results to return.
* Default: 0 (no pagination; show all results).
* @param string $filter Optional. Limit results to those matching a search
* string.
* @return array See {@link BP_Core_User::get_users()}.
*/
function friends_get_newest($user_id, $per_page = 0, $page = 0, $filter = '')
{
/**
* Filters a user's friends listed from newest to oldest.
*
* @since 1.2.0
*
* @param array {
* @type int $total_users Total number of users matched by query params.
* @type array $paged_users The current page of users matched by query params.
* }
*/
return apply_filters('friends_get_newest', BP_Core_User::get_users('newest', $per_page, $page, $user_id, $filter));
}
示例8: bp_core_get_users
/**
* Fetch an array of users based on the parameters passed.
*
* Since BuddyPress 1.7, bp_core_get_users() uses BP_User_Query. If you
* need backward compatibility with BP_Core_User::get_users(), filter the
* bp_use_legacy_user_query value, returning true.
*
* @param array $args {
* Array of arguments. All are optional. See {@link BP_User_Query} for
* a more complete description of arguments.
* @type string $type Sort order. Default: 'active'.
* @type int $user_id Limit results to friends of a user. Default: false.
* @type mixed $exclude IDs to exclude from results. Default: false.
* @type string $search_terms Limit to users matching search terms. Default: false.
* @type string $meta_key Limit to users with a meta_key. Default: false.
* @type string $meta_value Limit to users with a meta_value (with meta_key). Default: false.
* @type array|string $member_type Array or comma-separated string of member types.
* @type mixed $include Limit results by user IDs. Default: false.
* @type int $per_page Results per page. Default: 20.
* @type int $page Page of results. Default: 1.
* @type bool $populate_extras Fetch optional extras. Default: true.
* @type string|bool $count_total How to do total user count. Default: 'count_query'.
* }
* @return array
*/
function bp_core_get_users( $args = '' ) {
// Parse the user query arguments
$r = bp_parse_args( $args, array(
'type' => 'active', // active, newest, alphabetical, random or popular
'user_id' => false, // Pass a user_id to limit to only friend connections for this user
'exclude' => false, // Users to exclude from results
'search_terms' => false, // Limit to users that match these search terms
'meta_key' => false, // Limit to users who have this piece of usermeta
'meta_value' => false, // With meta_key, limit to users where usermeta matches this value
'member_type' => '',
'include' => false, // Pass comma separated list of user_ids to limit to only these users
'per_page' => 20, // The number of results to return per page
'page' => 1, // The page to return if limiting per page
'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false
), 'core_get_users' );
// For legacy users. Use of BP_Core_User::get_users() is deprecated.
if ( apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $r ) ) {
$retval = BP_Core_User::get_users(
$r['type'],
$r['per_page'],
$r['page'],
$r['user_id'],
$r['include'],
$r['search_terms'],
$r['populate_extras'],
$r['exclude'],
$r['meta_key'],
$r['meta_value']
);
// Default behavior as of BuddyPress 1.7
} else {
// Get users like we were asked to do...
$users = new BP_User_Query( $r );
// ...but reformat the results to match bp_core_get_users() behavior.
$retval = array(
'users' => array_values( $users->results ),
'total' => $users->total_users
);
}
/**
* Filters the results of the user query.
*
* @since BuddyPress (1.2.0)
*
* @param array $retval Array of users for the current query.
* @param array $r Array of parsed query arguments.
*/
return apply_filters( 'bp_core_get_users', $retval, $r );
}
示例9: bp_core_get_users
/**
* bp_core_get_users()
*
* Return an array of users IDs based on the parameters passed.
*
* @package BuddyPress Core
*/
function bp_core_get_users( $args = '' ) {
global $bp;
$defaults = array(
'type' => 'active', // active, newest, alphabetical, random or popular
'user_id' => false, // Pass a user_id to limit to only friend connections for this user
'search_terms' => false, // Limit to users that match these search terms
'include' => false, // Pass comma separated list of user_ids to limit to only these users
'per_page' => 20, // The number of results to return per page
'page' => 1, // The page to return if limiting per page
'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
);
$params = wp_parse_args( $args, $defaults );
extract( $params, EXTR_SKIP );
return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras ), &$params );
}