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


PHP BP_Core_User::search_users方法代码示例

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


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

示例1: bp_dtheme_ajax_messages_autocomplete_results

/**
 * bp_dtheme_ajax_messages_autocomplete_results()
 *
 * AJAX handler for autocomplete. Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined
 *
 * @global object object $bp Global BuddyPress settings object
 * @return none
 */
function bp_dtheme_ajax_messages_autocomplete_results()
{
    global $bp;
    // Include everyone in the autocomplete, or just friends?
    if ($bp->messages->slug == $bp->current_component) {
        $autocomplete_all = $bp->messages->autocomplete_all;
    }
    $friends = false;
    $pag_page = 1;
    $limit = $_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;
            }
            echo '<span id="link-' . $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)) . ' &nbsp;' . bp_core_get_user_displayname($user_id) . ' (' . $username . ')
			';
        }
    }
}
开发者ID:hscale,项目名称:webento,代码行数:57,代码来源:ajax.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' => '&laquo;', 'next_text' => '&raquo;', 'mid_size' => 1));
 }
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:51,代码来源:bp-core-templatetags.php

示例3: 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

示例4: 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

示例5: 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

示例6: test_search_users

 /**
  * @group search_users
  */
 public function test_search_users()
 {
     $u1 = $this->factory->user->create(array('display_name' => 'foo'));
     $u2 = $this->factory->user->create(array('display_name' => 'bar'));
     $q = BP_Core_User::search_users('ar');
     $found = array_map('intval', wp_list_pluck($q['users'], 'id'));
     $this->assertEquals(array($u2), $found);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:11,代码来源:class-bp-core-user.php


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