Created
January 14, 2019 21:33
-
-
Save KaineLabs/d1c7bdd8e913ac4752a7f10c592d357b to your computer and use it in GitHub Desktop.
Change Profile Username with Fullname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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