Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/d1c7bdd8e913ac4752a7f10c592d357b to your computer and use it in GitHub Desktop.
Save KaineLabs/d1c7bdd8e913ac4752a7f10c592d357b to your computer and use it in GitHub Desktop.
Change Profile Username with Fullname
<?php
/**
* Change Profile Username with Fullname.
*/
function yzc_change_profile_username_to_fullname( $member_name ) {
if ( ! bp_is_user() ) {
return $member_name;
}
// Get User Id.
$user_id = bp_displayed_user_id();
if ( $user_id == 0 ) {
return $member_name;
}
// Get User Data.
$user = get_userdata( $user_id );
// Get User Full Name.
$fullname = $user->user_firstname . ' ' . $user->user_lastname;
if ( empty( $fullname ) ) {
$fullname = $member_name;
}
return $fullname;
}
add_filter( 'yz_user_profile_username' , 'yzc_change_profile_username_to_fullname' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment