bp_get_member_name ()
获取循环中当前成员的显示名称。
描述
默认情况下,全名是从xprofile的全名字段中提取的。当该字段为空时,我们尝试从WP用户表中获取一个替代名称,优先级顺序如下:display_name、user_nicename、user_login。
返回
(字符串)要显示的用户全名。
源
文件:bp-members / bp-members-template.php
函数bp_get_member_name() {global $members_template;//通常,只有在禁用xprofile时才会触发。if (empty($members_template->member->fullname)){//其他fullname的优先顺序。$name_stack = array('display_name', 'user_nicename', 'user_login');foreach ($name_stack as $source) {if (!empty($members_template->member->{$source})){//当找到一个值时,将其设置为fullname并处理它。美元members_template - >成员> fullname = $ members_template - >成员- >{$源};打破;}}} $list_fields = bp_xprofile_get_hidden_fields_for_user($members_template->member->ID, bp_loggedin_user_id());If (empty($list_fields)) {$full_name = $members_template->member->fullname;} else {$last_name_field_id = bp_xprofile_lastname_field_id(); if ( in_array( $last_name_field_id, $list_fields ) ) { $last_name = $members_template->member->fullname; $full_name = str_replace( ' ' . $last_name, '', $members_template->member->fullname ); } else { $full_name = $members_template->member->fullname; } } /** * Filters the display name of current member in the loop. * * @since BuddyPress 1.2.0 * * @param string $fullname Display name for current member. */ return apply_filters( 'bp_get_member_name', trim( $full_name ) ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.2.0 | 介绍了。 |