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


PHP bp_core_get_user_displaynames函数代码示例

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


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

示例1: bp_xprofile_filter_user_query_populate_extras

/**
 * Filter BP_User_Query::populate_extras to override each queries users fullname.
 *
 * @since 1.7.0
 *
 * @param BP_User_Query $user_query   User query to filter.
 * @param string        $user_ids_sql SQL statement to use.
 */
function bp_xprofile_filter_user_query_populate_extras(BP_User_Query $user_query, $user_ids_sql = '')
{
    if (!bp_is_active('xprofile')) {
        return;
    }
    $user_id_names = bp_core_get_user_displaynames($user_query->user_ids);
    // Loop through names and override each user's fullname.
    foreach ($user_id_names as $user_id => $user_fullname) {
        if (isset($user_query->results[$user_id])) {
            $user_query->results[$user_id]->fullname = $user_fullname;
        }
    }
}
开发者ID:boonebgorges,项目名称:BuddyPress-1,代码行数:21,代码来源:bp-xprofile-filters.php

示例2: bp_core_get_user_displayname

/**
 * Fetch the display name for a user.
 *
 * @since 1.0.1
 *
 * @param int|string|bool $user_id_or_username User ID or username.
 * @return string|bool The display name for the user in question, or false if
 *                     user not found.
 */
function bp_core_get_user_displayname($user_id_or_username)
{
    if (empty($user_id_or_username)) {
        return false;
    }
    if (!is_numeric($user_id_or_username)) {
        $user_id = bp_core_get_userid($user_id_or_username);
    } else {
        $user_id = $user_id_or_username;
    }
    if (empty($user_id)) {
        return false;
    }
    $display_names = bp_core_get_user_displaynames(array($user_id));
    if (!isset($display_names[$user_id])) {
        $fullname = false;
    } else {
        $fullname = $display_names[$user_id];
    }
    /**
     * Filters the display name for the passed in user.
     *
     * @since 1.0.1
     *
     * @param string $fullname Display name for the user.
     * @param int    $user_id  ID of the user to check.
     */
    return apply_filters('bp_core_get_user_displayname', $fullname, $user_id);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:38,代码来源:bp-members-functions.php

示例3: test_bp_core_get_user_displaynames_one_in_cache

 /**
  * @group bp_core_get_user_displaynames
  */
 public function test_bp_core_get_user_displaynames_one_in_cache()
 {
     $u1 = $this->factory->user->create();
     xprofile_set_field_data(1, $u1, 'Foo');
     // Fake the cache for $u2
     $u2 = 123;
     wp_cache_set('bp_user_fullname_' . $u2, 'Bar', 'bp');
     $expected = array($u1 => 'Foo', $u2 => 'Bar');
     $this->assertSame($expected, bp_core_get_user_displaynames(array($u1, $u2)));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:13,代码来源:functions.php

示例4: append_user_fullnames

 /**
  * Append xProfile fullnames to an activity array.
  *
  * @since 2.0.0
  *
  * @param array $activities Activities array.
  * @return array
  */
 protected static function append_user_fullnames($activities)
 {
     if (bp_is_active('xprofile') && !empty($activities)) {
         $activity_user_ids = wp_list_pluck($activities, 'user_id');
         if (!empty($activity_user_ids)) {
             $fullnames = bp_core_get_user_displaynames($activity_user_ids);
             if (!empty($fullnames)) {
                 foreach ((array) $activities as $i => $activity) {
                     if (!empty($fullnames[$activity->user_id])) {
                         $activities[$i]->user_fullname = $fullnames[$activity->user_id];
                     }
                 }
             }
         }
     }
     return $activities;
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:25,代码来源:class-bp-activity-activity.php

示例5: bp_core_get_user_displayname

/**
 * Fetch the display name for a user.
 *
 * @param int|string $user_id_or_username User ID or username.
 * @return string|bool The display name for the user in question, or false if
 *         user not found.
 */
function bp_core_get_user_displayname($user_id_or_username)
{
    $fullname = '';
    if (empty($user_id_or_username)) {
        return false;
    }
    if (!is_numeric($user_id_or_username)) {
        $user_id = bp_core_get_userid($user_id_or_username);
    } else {
        $user_id = $user_id_or_username;
    }
    if (empty($user_id)) {
        return false;
    }
    $display_names = bp_core_get_user_displaynames(array($user_id));
    if (!isset($display_names[$user_id])) {
        $fullname = false;
    } else {
        $fullname = $display_names[$user_id];
    }
    return apply_filters('bp_core_get_user_displayname', $fullname, $user_id);
}
开发者ID:eresyyl,项目名称:mk,代码行数:29,代码来源:bp-members-functions.php


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