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


PHP BP_Core_User类代码示例

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


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

示例1: bp_core_members_template

	function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras ) {
		global $bp;

		$this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : $page_number;
		$this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
		$this->type     = $type;

		if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
			$this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras );
		else
			$this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );

		if ( !$max || $max >= (int)$this->members['total'] )
			$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 );
		}

		if ( (int)$this->total_member_count && (int)$this->pag_num ) {
			$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:n-sane,项目名称:zaroka,代码行数:41,代码来源:bp-core-templatetags.php

示例2: 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
}
开发者ID:n-sane,项目名称:zaroka,代码行数:37,代码来源:bp-friends-templatetags.php

示例3: __construct

 function __construct($type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value)
 {
     global $bp;
     $this->pag_page = !empty($_REQUEST['upage']) ? intval($_REQUEST['upage']) : (int) $page_number;
     $this->pag_num = !empty($_REQUEST['num']) ? intval($_REQUEST['num']) : (int) $per_page;
     $this->type = $type;
     if (isset($_REQUEST['letter']) && '' != $_REQUEST['letter']) {
         $this->members = BP_Core_User::get_users_by_letter($_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude);
     } else {
         if (false !== $include) {
             $this->members = BP_Core_User::get_specific_users($include, $this->pag_num, $this->pag_page, $populate_extras);
         } else {
             $this->members = bp_core_get_users(array('type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value));
         }
     }
     if (!$max || $max >= (int) $this->members['total']) {
         $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);
     }
     if ((int) $this->total_member_count && (int) $this->pag_num) {
         $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' => _x('&larr;', 'Member pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Member pagination next text', 'buddypress'), 'mid_size' => 1));
     }
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:34,代码来源:bp-members-template.php

示例4: bp_dtheme_ajax_messages_autocomplete_results

/**
 * AJAX handler for autocomplete. Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_dtheme_ajax_messages_autocomplete_results()
{
    // Include everyone in the autocomplete, or just friends?
    if (bp_is_current_component(bp_get_messages_slug())) {
        $autocomplete_all = buddypress()->messages->autocomplete_all;
    }
    $pag_page = 1;
    $limit = (int) $_GET['limit'] ? $_GET['limit'] : apply_filters('bp_autocomplete_max_results', 10);
    // Get the user ids based on the search terms
    if (!empty($autocomplete_all)) {
        $users = BP_Core_User::search_users($_GET['q'], $limit, $pag_page);
        if (!empty($users['users'])) {
            // Build an array with the correct format
            $user_ids = array();
            foreach ($users['users'] as $user) {
                if ($user->id != bp_loggedin_user_id()) {
                    $user_ids[] = $user->id;
                }
            }
            $user_ids = apply_filters('bp_core_autocomplete_ids', $user_ids, $_GET['q'], $limit);
        }
    } else {
        if (bp_is_active('friends')) {
            $users = friends_search_friends($_GET['q'], bp_loggedin_user_id(), $limit, 1);
            // Keeping the bp_friends_autocomplete_list filter for backward compatibility
            $users = apply_filters('bp_friends_autocomplete_list', $users, $_GET['q'], $limit);
            if (!empty($users['friends'])) {
                $user_ids = apply_filters('bp_friends_autocomplete_ids', $users['friends'], $_GET['q'], $limit);
            }
        }
    }
    if (!empty($user_ids)) {
        foreach ($user_ids as $user_id) {
            $ud = get_userdata($user_id);
            if (!$ud) {
                continue;
            }
            if (bp_is_username_compatibility_mode()) {
                $username = $ud->user_login;
            } else {
                $username = $ud->user_nicename;
            }
            // Note that the final line break acts as a delimiter for the
            // autocomplete javascript and thus should not be removed
            echo '<span id="link-' . esc_attr($username) . '" href="' . bp_core_get_user_domain($user_id) . '"></span>' . bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15, 'alt' => $ud->display_name)) . ' &nbsp;' . bp_core_get_user_displayname($user_id) . ' (' . esc_html($username) . ')' . "\n";
        }
    }
    exit;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:55,代码来源:ajax.php

示例5: 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));
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:bp-friends-functions.php

示例6: bp_core_widget_whos_online

function bp_core_widget_whos_online($args)
{
    global $current_blog;
    extract($args);
    $options = get_blog_option($current_blog->blog_id, 'bp_core_widget_whos_online');
    ?>
	<?php 
    echo $before_widget;
    ?>
	<?php 
    echo $before_title . $widget_name . $after_title;
    ?>

	<?php 
    if (!($users = wp_cache_get('online_users', 'bp'))) {
        $users = BP_Core_User::get_online_users($options['max_members']);
        wp_cache_set('online_users', $users, 'bp');
    }
    ?>

	<?php 
    $users = BP_Core_User::get_online_users($options['max_members']);
    ?>

	<?php 
    if ($users['users']) {
        ?>
		<div class="avatar-block">
		<?php 
        foreach ((array) $users['users'] as $user) {
            ?>
			<div class="item-avatar">
				<a href="<?php 
            echo bp_core_get_userurl($user->user_id);
            ?>
" title="<?php 
            bp_fetch_user_fullname($user->user_id, true);
            ?>
"><?php 
            echo bp_core_get_avatar($user->user_id, 1);
            ?>
</a>
			</div>
		<?php 
        }
        ?>
		</div>
			
		<?php 
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('bp_core_widget_members', '_wpnonce-members');
        }
        ?>

		<input type="hidden" name="bp_core_widget_members_max" id="bp_core_widget_members_max" value="<?php 
        echo attribute_escape($options['max_members']);
        ?>
" />

	<?php 
    } else {
        ?>
		<div class="widget-error">
			<?php 
        _e('There are no users currently online.', 'buddypress');
        ?>
		</div>
	<?php 
    }
    ?>

	<?php 
    echo $after_widget;
    ?>
	
	<div class="clear" style="margin-bottom: 25px"></div>
	
<?php 
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:79,代码来源:bp-core-widgets.php

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

示例8: populate_extras

 /**
  * Perform a database query to populate any extra metadata we might need.
  *
  * Different components will hook into the 'bp_user_query_populate_extras'
  * action to loop in the things they want.
  *
  * @since 1.7.0
  *
  * @global WPDB $wpdb Global WordPress database access object.
  */
 public function populate_extras()
 {
     global $wpdb;
     // Bail if no users.
     if (empty($this->user_ids) || empty($this->results)) {
         return;
     }
     // Bail if the populate_extras flag is set to false
     // In the case of the 'popular' sort type, we force
     // populate_extras to true, because we need the friend counts.
     if ('popular' == $this->query_vars['type']) {
         $this->query_vars['populate_extras'] = 1;
     }
     if (!(bool) $this->query_vars['populate_extras']) {
         return;
     }
     // Turn user ID's into a query-usable, comma separated value.
     $user_ids_sql = implode(',', wp_parse_id_list($this->user_ids));
     /**
      * Allows users to independently populate custom extras.
      *
      * Note that anything you add here should query using $user_ids_sql, to
      * avoid running multiple queries per user in the loop.
      *
      * Two BuddyPress components currently do this:
      * - XProfile: To override display names.
      * - Friends:  To set whether or not a user is the current users friend.
      *
      * @see bp_xprofile_filter_user_query_populate_extras()
      * @see bp_friends_filter_user_query_populate_extras()
      *
      * @since 1.7.0
      *
      * @param BP_User_Query $this         Current BP_User_Query instance.
      * @param string        $user_ids_sql Comma-separated string of user IDs.
      */
     do_action_ref_array('bp_user_query_populate_extras', array($this, $user_ids_sql));
     // Fetch last_active data from the activity table.
     $last_activities = BP_Core_User::get_last_activity($this->user_ids);
     // Set a last_activity value for each user, even if it's empty.
     foreach ($this->results as $user_id => $user) {
         $user_last_activity = isset($last_activities[$user_id]) ? $last_activities[$user_id]['date_recorded'] : '';
         $this->results[$user_id]->last_activity = $user_last_activity;
     }
     // Fetch usermeta data
     // We want the three following pieces of info from usermeta:
     // - friend count
     // - latest update.
     $total_friend_count_key = bp_get_user_meta_key('total_friend_count');
     $bp_latest_update_key = bp_get_user_meta_key('bp_latest_update');
     // Total_friend_count must be set for each user, even if its
     // value is 0.
     foreach ($this->results as $uindex => $user) {
         $this->results[$uindex]->total_friend_count = 0;
     }
     // Create, prepare, and run the separate usermeta query.
     $user_metas = $wpdb->get_results($wpdb->prepare("SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} WHERE meta_key IN (%s,%s) AND user_id IN ({$user_ids_sql})", $total_friend_count_key, $bp_latest_update_key));
     // The $members_template global expects the index key to be different
     // from the meta_key in some cases, so we rejig things here.
     foreach ($user_metas as $user_meta) {
         switch ($user_meta->meta_key) {
             case $total_friend_count_key:
                 $key = 'total_friend_count';
                 break;
             case $bp_latest_update_key:
                 $key = 'latest_update';
                 break;
         }
         if (isset($this->results[$user_meta->user_id])) {
             $this->results[$user_meta->user_id]->{$key} = $user_meta->meta_value;
         }
     }
     // When meta_key or meta_value have been passed to the query,
     // fetch the resulting values for use in the template functions.
     if (!empty($this->query_vars['meta_key'])) {
         $meta_sql = array('select' => "SELECT user_id, meta_key, meta_value", 'from' => "FROM {$wpdb->usermeta}", 'where' => $wpdb->prepare("WHERE meta_key = %s", $this->query_vars['meta_key']));
         if (false !== $this->query_vars['meta_value']) {
             $meta_sql['where'] .= $wpdb->prepare(" AND meta_value = %s", $this->query_vars['meta_value']);
         }
         $metas = $wpdb->get_results("{$meta_sql['select']} {$meta_sql['from']} {$meta_sql['where']}");
         if (!empty($metas)) {
             foreach ($metas as $meta) {
                 if (isset($this->results[$meta->user_id])) {
                     $this->results[$meta->user_id]->meta_key = $meta->meta_key;
                     if (!empty($meta->meta_value)) {
                         $this->results[$meta->user_id]->meta_value = $meta->meta_value;
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:class-bp-user-query.php

示例9: __construct

 /**
  * Constructor method.
  *
  * @see BP_User_Query for an in-depth description of parameters.
  *
  * @param string       $type                Sort order.
  * @param int          $page_number         Page of results.
  * @param int          $per_page            Number of results per page.
  * @param int          $max                 Max number of results to return.
  * @param int          $user_id             Limit to friends of a user.
  * @param string       $search_terms        Limit to users matching search terms.
  * @param array        $include             Limit results by these user IDs.
  * @param bool         $populate_extras     Fetch optional extras.
  * @param array        $exclude             Exclude these IDs from results.
  * @param array        $meta_key            Limit to users with a meta_key.
  * @param array        $meta_value          Limit to users with a meta_value (with meta_key).
  * @param string       $page_arg            Optional. The string used as a query parameter in pagination links.
  *                                          Default: 'upage'.
  * @param array|string $member_type         Array or comma-separated string of member types to limit results to.
  * @param array|string $member_type__in     Array or comma-separated string of member types to limit results to.
  * @param array|string $member_type__not_in Array or comma-separated string of member types to exclude
  *                                          from results.
  */
 function __construct($type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage', $member_type = '', $member_type__in = '', $member_type__not_in = '')
 {
     $this->pag_arg = sanitize_key($page_arg);
     $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page_number);
     $this->pag_num = bp_sanitize_pagination_arg('num', $per_page);
     $this->type = $type;
     if (!empty($_REQUEST['letter'])) {
         $this->members = BP_Core_User::get_users_by_letter($_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude);
     } else {
         $this->members = bp_core_get_users(array('type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value, 'member_type' => $member_type, 'member_type__in' => $member_type__in, 'member_type__not_in' => $member_type__not_in));
     }
     if (!$max || $max >= (int) $this->members['total']) {
         $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);
     }
     if ((int) $this->total_member_count && (int) $this->pag_num) {
         $pag_args = array($this->pag_arg => '%#%');
         if (defined('DOING_AJAX') && true === (bool) DOING_AJAX) {
             $base = remove_query_arg('s', wp_get_referer());
         } else {
             $base = '';
         }
         /**
          * Defaults to an empty array to make sure paginate_links()
          * won't add the $page_arg to the links which would break
          * pagination in case JavaScript is disabled.
          */
         $add_args = array();
         if (!empty($search_terms)) {
             $query_arg = bp_core_get_component_search_query_arg('members');
             $add_args[$query_arg] = urlencode($search_terms);
         }
         $this->pag_links = paginate_links(array('base' => add_query_arg($pag_args, $base), 'format' => '', 'total' => ceil((int) $this->total_member_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('&larr;', 'Member pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Member pagination next text', 'buddypress'), 'mid_size' => 1, 'add_args' => $add_args));
     }
 }
开发者ID:mawilliamson,项目名称:wordpress,代码行数:69,代码来源:bp-members-template.php

示例10: invite_anyone_ajax_autocomplete_results

function invite_anyone_ajax_autocomplete_results()
{
    global $bp;
    $friends = false;
    // Get the friend ids based on the search terms
    $friends = BP_Core_User::search_users($_GET['q'], 500, 1);
    $friends = apply_filters('bp_friends_autocomplete_list', $friends, $_GET['q'], $_GET['limit']);
    if ($friends['users']) {
        foreach ($friends['users'] as $user) {
            if ($user->user_id) {
                // For BP < 1.2
                $user_id = $user->user_id;
            } else {
                $user_id = $user->id;
            }
            $ud = get_userdata($user_id);
            $username = $ud->user_login;
            echo bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'width' => 25, 'height' => 25)) . ' ' . bp_core_get_user_displayname($user->user_id) . ' (' . $username . ')
			';
        }
    }
}
开发者ID:hnla,项目名称:invite-anyone,代码行数:22,代码来源:group-invites.php

示例11: __construct

 /**
  * Constructor method.
  *
  * @see BP_User_Query for an in-depth description of parameters.
  *
  * @param string $type Sort order.
  * @param int $page_number Page of results.
  * @param int $per_page Number of results per page.
  * @param int $max Max number of results to return.
  * @param int $user_id Limit to friends of a user.
  * @param string $search_terms Limit to users matching search terms.
  * @param array $include Limit results by these user IDs.
  * @param bool $populate_extras Fetch optional extras.
  * @param array $exclude Exclude these IDs from results.
  * @param array $meta_key Limit to users with a meta_key.
  * @param array $meta_value Limit to users with a meta_value (with meta_key).
  * @param array $page_arg Optional. The string used as a query
  *        parameter in pagination links. Default: 'upage'.
  */
 function __construct($type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage')
 {
     $this->pag_page = !empty($_REQUEST[$page_arg]) ? intval($_REQUEST[$page_arg]) : (int) $page_number;
     $this->pag_num = !empty($_REQUEST['num']) ? intval($_REQUEST['num']) : (int) $per_page;
     $this->type = $type;
     if (!empty($_REQUEST['letter'])) {
         $this->members = BP_Core_User::get_users_by_letter($_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude);
     } else {
         $this->members = bp_core_get_users(array('type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value));
     }
     if (!$max || $max >= (int) $this->members['total']) {
         $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);
     }
     if ((int) $this->total_member_count && (int) $this->pag_num) {
         $pag_args = array($page_arg => '%#%');
         if (defined('DOING_AJAX') && true === (bool) DOING_AJAX) {
             $base = remove_query_arg('s', wp_get_referer());
         } else {
             $base = '';
         }
         if (!empty($search_terms)) {
             $pag_args['s'] = $search_terms;
         }
         $this->pag_links = paginate_links(array('base' => add_query_arg($pag_args, $base), 'format' => '', 'total' => ceil((int) $this->total_member_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('&larr;', 'Member pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Member pagination next text', 'buddypress'), 'mid_size' => 1));
     }
 }
开发者ID:eresyyl,项目名称:mk,代码行数:57,代码来源:bp-members-template.php

示例12: bp_gtm_search_users

function bp_gtm_search_users($search_terms, $limit = 10, $page = 1, $populate_extras = true)
{
    return BP_Core_User::search_users($search_terms, $limit, $page, $populate_extras);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:4,代码来源:bp-gtm-functions.php

示例13: search_users

 /**
  * Find users who match on the value of an xprofile data.
  *
  * @global object $bp Global BuddyPress settings object
  * @global nxtdb $nxtdb NXTClass database object
  * @param string $search_terms The terms to search the profile table value column for.
  * @param integer $limit The limit of results we want.
  * @param integer $page The page we are on for pagination.
  * @param boolean $populate_extras Populate extra user fields?
  * @return array Associative array
  * @static
  */
 function search_users($search_terms, $limit = null, $page = 1, $populate_extras = true)
 {
     global $bp, $nxtdb;
     $pag_sql = $limit && $page ? $nxtdb->prepare(" LIMIT %d, %d", intval(($page - 1) * intval($limit)), intval($limit)) : '';
     $search_terms = like_escape($nxtdb->escape($search_terms));
     $status_sql = bp_core_get_status_sql('u.');
     $total_users_sql = apply_filters('bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as id FROM {$nxtdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND 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 id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$nxtdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql);
     $total_users = $nxtdb->get_var($total_users_sql);
     $paged_users = $nxtdb->get_results($paged_users_sql);
     /***
      * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
      * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
      */
     foreach ((array) $paged_users as $user) {
         $user_ids[] = $user->id;
     }
     $user_ids = $nxtdb->escape(join(',', (array) $user_ids));
     // Add additional data to the returned results
     if ($populate_extras) {
         $paged_users = BP_Core_User::get_user_extras($paged_users, $user_ids);
     }
     return array('users' => $paged_users, 'total' => $total_users);
 }
开发者ID:nxtclass,项目名称:NXTClass,代码行数:36,代码来源:bp-core-classes.php

示例14: test_delete_last_activity

 /**
  * @group last_activity
  */
 public function test_delete_last_activity()
 {
     $u = $this->factory->user->create();
     $time = bp_core_current_time();
     BP_Core_User::update_last_activity($u, $time);
     $a = BP_Core_User::get_last_activity($u);
     $found = isset($a[$u]['date_recorded']) ? $a[$u]['date_recorded'] : '';
     $this->assertEquals($time, $found);
     BP_Core_User::delete_last_activity($u);
     $a = BP_Core_User::get_last_activity($u);
     $found = isset($a[$u]['date_recorded']) ? $a[$u]['date_recorded'] : '';
     $this->assertEquals('', $found);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:16,代码来源:class-bp-core-user.php

示例15: bp_core_get_core_userdata

/**
 * Fetch everything in the wp_users table for a user, without any usermeta.
 *
 * @package BuddyPress Core
 * @param user_id The ID of the user.
 * @uses BP_Core_User::get_core_userdata() Performs the query.
 */
function bp_core_get_core_userdata($user_id)
{
    if (empty($user_id)) {
        return false;
    }
    if (!($userdata = wp_cache_get('bp_core_userdata_' . $user_id, 'bp'))) {
        $userdata = BP_Core_User::get_core_userdata($user_id);
        wp_cache_set('bp_core_userdata_' . $user_id, $userdata, 'bp');
    }
    return apply_filters('bp_core_get_core_userdata', $userdata);
}
开发者ID:hornetalcala,项目名称:trunk,代码行数:18,代码来源:bp-members-functions.php


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