Contents
bp_core_get_user_displayname( int|string|bool $user_id_or_username )
Fetch the display name for a user.
Description
Parameters
- $user_id_or_username
-
(Required) User ID or username.
Return
(string|bool) The display name for the user in question, or false if user not found.
Source
File: bp-members/bp-members-functions.php
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | 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; } $list_fields = bp_xprofile_get_hidden_fields_for_user( $user_id , bp_loggedin_user_id()); if ( empty ( $list_fields ) ) { $full_name = get_the_author_meta( 'display_name' , $user_id ); if ( empty ( $full_name ) ) { $full_name = get_the_author_meta( 'nickname' , $user_id ); } } else { $last_name_field_id = bp_xprofile_lastname_field_id(); if ( in_array( $last_name_field_id , $list_fields ) ) { $last_name = xprofile_get_field_data( $last_name_field_id , $user_id ); $full_name = str_replace ( ' ' . $last_name , '' , get_the_author_meta( 'display_name' , $user_id ) ); } else { $full_name = get_the_author_meta( 'display_name' , $user_id ); } } if ( empty ( $full_name ) && empty ( get_userdata( $user_id ) ) ) { $full_name = __( 'Deleted User' , 'buddyboss' ); } /** * Filters the display name for the passed in user. * * @since BuddyPress 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' , trim( $full_name ), $user_id ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.0.1 | Introduced. |
Related
Uses
Uses | Description |
---|---|
bp-xprofile/bp-xprofile-functions.php: bp_xprofile_get_hidden_fields_for_user() |
Get the ids of fields that are hidden for this displayed/loggedin user pair. |
bp-xprofile/bp-xprofile-functions.php: bp_xprofile_lastname_field_id() |
Get the field id of the last name field |
bp-xprofile/bp-xprofile-functions.php: xprofile_get_field_data() |
Fetches profile data for a specific field for the user. |
bp-members/bp-members-functions.php: bp_core_get_user_displayname |
Filters the display name for the passed in user. |
bp-members/bp-members-functions.php: bp_core_get_userid() |
Return the user ID based on a user’s user_login. |
bp-core/bp-core-template.php: bp_loggedin_user_id() |
Get the ID of the currently logged-in user. |
Used By | Description |
---|---|
bp-media/bp-media-template.php: bp_get_album_author() |
Return the album author name. |
bp-media/bp-media-template.php: bp_get_media_author() |
Return the Media author name. |
bp-document/bp-document-template.php: bp_get_document_author() |
Return the document name. |
bp-document/bp-document-template.php: bp_get_folder_author() |
Return the document name. |
bp-templates/bp-nouveau/includes/document/ajax.php: bp_nouveau_ajax_document_get_document_description() |
Get description for the document. |
bp-templates/bp-nouveau/includes/messages/ajax.php: bp_nouveau_get_thread_messages() |
messages for each thread. |
bp-templates/bp-nouveau/includes/media/ajax.php: bp_nouveau_ajax_media_get_media_description() |
Get description for the media. |
bp-templates/bp-nouveau/includes/groups/ajax.php: bp_nouveau_ajax_groups_get_group_members_listing() |
Retrieve the possible members list to send group message. |
bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php: BP_REST_Account_Settings_Options_Endpoint::update_general_fields() |
Update general fields. |
bp-messages/bp-messages-functions.php: bp_messages_get_avatars() |
Get Message thread avatars by thread id. |
bp-messages/bp-messages-functions.php: group_messages_notification_new_message() |
Email message recipients to alert them of a new unread group message. |
bp-messages/classes/class-bp-rest-messages-endpoint.php: BP_REST_Messages_Endpoint::prepare_recipient_for_response() |
Prepares recipient data for the REST response. |
bp-members/classes/class-bp-rest-members-endpoint.php: BP_REST_Members_Endpoint::user_data() |
Method to facilitate fetching of user data. |
bp-invites/classes/class-bp-rest-invites-endpoint.php: BP_REST_Invites_Endpoint::create_item() |
Create an Invites/Send Invites. |
bp-groups/bp-groups-functions.php: bp_groups_prime_mentions_results() |
Mentions results for groups. |
bp-friends/classes/class-bp-core-friends-widget.php: BP_Core_Friends_Widget::get_user_display_name() |
Display user name to ‘First Name’ when they have selected ‘First Name & Last Name’ in display format. |
bp-core/classes/class-bp-core-follow-follower-widget.php: BP_Core_Follow_Follower_Widget::widget() |
Displays the widget. |
bp-core/classes/class-bp-core-follow-follower-widget.php: BP_Core_Follow_Follower_Widget::get_user_display_name() |
Display user name to ‘First Name’ when they have selected ‘First Name & Last Name’ in display format. |
bp-core/classes/class-bp-core-follow-following-widget.php: BP_Core_Follow_Following_Widget::get_user_display_name() |
Display user name to ‘First Name’ when they have selected ‘First Name & Last Name’ in display format. |
bp-activity/classes/class-bp-rest-activity-endpoint.php: BP_REST_Activity_Endpoint::prepare_item_for_response() |
Prepares activity data for return as an object. |
bp-core/bp-core-adminbar.php: bp_wp_admin_bar_my_account_menu() |
Add the “My Account” submenu items. |
bp-settings/actions/general.php: bp_settings_action_general() |
Handles the changing and saving of user email addresses and passwords. |
bp-forums/notifications.php: bbp_format_buddypress_notifications() |
Format the BuddyBar/Toolbar notifications |
bp-blogs/bp-blogs-activity.php: bp_blogs_sync_add_from_activity_comment() |
Syncs activity comments and posts them back as blog comments. |
bp-blogs/bp-blogs-template.php: bp_get_blog_avatar() |
Get a blog’s avatar. |
bp-xprofile/bp-xprofile-activity.php: bp_xprofile_format_activity_action_updated_profile() |
Format ‘updated_profile’ activity actions. |
bp-xprofile/bp-xprofile-filters.php: bp_xprofile_replace_username_to_display_name() |
Change display_name for admin areas. |
bp-xprofile/bp-xprofile-filters.php: bp_xprofile_adjust_current_user_display_name() |
Change member display_name for current_user. |
bp-xprofile/bp-xprofile-filters.php: bp_xprofile_adjust_display_name() |
Change member display_name for user_metadata. |
bp-xprofile/bp-xprofile-functions.php: bp_xprofile_update_display_name() |
Update display_name in user database. |
bp-xprofile/bp-xprofile-functions.php: xprofile_override_user_fullnames() |
Replace the displayed and logged-in users fullnames with the xprofile name, if required. |
bp-xprofile/classes/class-bp-xprofile-user-admin.php: BP_XProfile_User_Admin::user_admin_spammer_metabox() |
Render the fallback metabox in case a user has been marked as a spammer. |
bp-messages/bp-messages-template.php: bp_get_the_thread_message_sender_name() |
Get the display name of the sender of the current message. |
bp-messages/bp-messages-template.php: bp_get_the_thread_message_sender_avatar_thumb() |
Get the avatar for the current message sender. |
bp-messages/bp-messages-template.php: bp_get_message_thread_avatar() |
Return the avatar for the last sender in the current message thread. |
bp-messages/bp-messages-functions.php: messages_notification_new_message() |
Email message recipients to alert them of a new unread private message. |
bp-messages/bp-messages-notifications.php: messages_format_notifications() |
Format notifications for the Messages component. |
bp-groups/classes/class-bp-groups-member-suggestions.php: BP_Groups_Member_Suggestions::get_suggestions() |
Find and return a list of username suggestions that match the query. |
bp-groups/bp-groups-functions.php: bp_groups_get_invited_by() |
Get inviter for member’s group invitation |
bp-groups/bp-groups-template.php: bp_group_request_user_avatar_thumb() |
Output avatar of current membership request. |
bp-groups/bp-groups-template.php: bp_get_group_member_link() |
Get the anchor tag of the group member profile url with link of displayed name. |
bp-groups/bp-groups-template.php: bp_group_admin_memberlist() |
Since BuddyPress 1.0, this generated the group settings admin/member screen. |
bp-groups/bp-groups-template.php: bp_group_mod_memberlist() |
Generate the HTML for a list of group moderators. |
bp-groups/bp-groups-template.php: bp_group_list_admins() |
Output markup listing group admins. |
bp-groups/bp-groups-template.php: bp_group_list_mods() |
Output markup listing group mod. |
bp-groups/bp-groups-template.php: bp_get_group_creator_avatar() |
Return the avatar of the creator of the current group in the loop. |
bp-groups/bp-groups-template.php: bp_get_group_creator_username() |
Return the username of the creator of the current group in the loop. |
bp-groups/bp-groups-notifications.php: groups_notification_new_membership_request() |
Notify group admin about new membership request. |
bp-groups/bp-groups-notifications.php: groups_format_notifications() |
Format notifications for the Groups component. |
bp-members/bp-members-functions.php: bp_core_get_userlink() |
Return a HTML formatted link for a user with the user’s full name as the link text. |
bp-members/bp-members-functions.php: bp_core_get_user_displaynames() |
Fetch the display name for a group of users. |
bp-members/classes/class-bp-members-admin.php: BP_Members_Admin::user_admin_spammer_metabox() |
Render the fallback metabox in case a user has been marked as a spammer. |
bp-members/classes/class-bp-members-admin.php: BP_Members_Admin::user_admin_load() |
Set up the user’s profile admin page. |
bp-invites/bp-invites-admin.php: bp_invite_show_data() |
Display data by column and post id. |
bp-invites/bp-invites-functions.php: bp_get_member_invites_wildcard_replace() |
Replaces the token, {{ }}, to it’s appropriate content dynamically. |
bp-invites/bp-invites-functions.php: bp_invites_member_invite_register_screen_message() |
Checks if the email is connected to an active invite, populates the email address and shows the welcome message on the register page. |
bp-invites/actions/invites.php: bp_member_invite_submit() |
Member submit email invite. |
bp-friends/bp-friends-functions.php: friends_notification_new_request() |
Send notifications related to a new friendship request. |
bp-friends/bp-friends-functions.php: friends_notification_accepted_request() |
Send notifications related to the acceptance of a connection request. |
bp-friends/bp-friends-functions.php: bp_friends_prime_mentions_results() |
Used by the Activity component’s @mentions to print a JSON list of the current user’s friends. |
bp-friends/bp-friends-notifications.php: friends_format_notifications() |
Notification formatting callback for bp-friends notifications. |
bp-templates/bp-nouveau/includes/activity/functions.php: bp_nouveau_activity_localize_scripts() |
Localize the strings needed for the Activity Post form UI |
bp-templates/bp-nouveau/includes/messages/ajax.php: bp_nouveau_ajax_messages_send_message() |
AJAX send message and display error. |
bp-templates/bp-nouveau/includes/messages/ajax.php: bp_nouveau_ajax_get_user_message_threads() |
AJAX get all user message threads. |
bp-templates/bp-nouveau/includes/groups/functions.php: bp_nouveau_prepare_group_potential_invites_for_js() |
Prepare list of group invites for JS. |
bp-core/admin/bp-core-admin-tools.php: xprofile_update_display_names() |
Update member display names. |
bp-core/deprecated/buddypress/1.5.php: groups_at_message_notification() |
Send an email and a BP notification on receipt of an @-mention in a group |
bp-core/bp-core-wp-emails.php: wp_notify_postauthor() |
Notify an author (and/or others) of a comment/trackback/pingback on a post. |
bp-core/bp-core-wp-emails.php: wp_notify_moderator() |
Notifies the moderator of the site about a new comment that is awaiting approval. |
bp-core/bp-core-template.php: bp_comment_author_avatar() |
Output a comment author’s avatar. |
bp-core/bp-core-template.php: bp_post_author_avatar() |
Output a post author’s avatar. |
bp-core/classes/class-bp-email-recipient.php: BP_Email_Recipient::__construct() |
Constructor. |
bp-core/classes/class-bp-email-tokens.php: BP_Email_Tokens::token__group_card() |
Generate the output for token group.card |
bp-core/classes/class-bp-email-tokens.php: BP_Email_Tokens::token__status_update() |
Generate the output for token status_update |
bp-core/classes/class-bp-email-tokens.php: BP_Email_Tokens::token__activity_reply() |
Generate the output for token activity_reply |
bp-core/classes/class-bp-email-tokens.php: BP_Email_Tokens::token__member_card_small() |
Generate the output for token member.card |
bp-core/classes/class-bp-core-follow-following-widget.php: BP_Core_Follow_Following_Widget::widget() |
Displays the widget. |
bp-core/classes/class-bp-core-user.php: BP_Core_User::populate() |
Populate the instantiated class with data based on the User ID provided. |
bp-core/classes/class-bp-members-suggestions.php: BP_Members_Suggestions::get_suggestions() |
Find and return a list of username suggestions that match the query. |
bp-core/bp-core-avatars.php: bp_core_fetch_avatar() |
Get an avatar for a BuddyPress object. |
bp-activity/bp-activity-functions.php: bp_activity_new_comment_notification() |
Send email and BP notifications when an activity item receives a comment. |
bp-activity/bp-activity-functions.php: bp_activity_at_message_notification() |
Send email and BP notifications when a user is mentioned in an update. |
bp-activity/bp-activity-functions.php: bp_activity_get_favorite_users_string() |
Get like count for activity |
bp-activity/bp-activity-functions.php: bp_activity_get_favorite_users_tooltip_string() |
Get users for activity favorite tooltip |
bp-activity/bp-activity-notifications.php: bp_activity_format_notifications() |
Format notifications related to activity. |
bp-activity/classes/class-bp-activity-oembed-extension.php: BP_Activity_oEmbed_Extension::set_oembed_response_data() |
Sets the oEmbed response data for our activity item. |
bp-activity/classes/class-bp-activity-oembed-extension.php: BP_Activity_oEmbed_Extension::set_fallback_html() |
Sets a custom |
bp-activity/bp-activity-template.php: bp_get_mentioned_user_display_name() |
Returns the mentioned user display name. |
bp-activity/bp-activity-template.php: bp_get_activity_secondary_avatar() |
Return the avatar of the object that action was performed on. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.