Created
November 18, 2020 07:42
-
-
Save imanispatel/92fe163e3b6e20b7619a8a3d73ea7a68 to your computer and use it in GitHub Desktop.
Change my and friends profile data example: change user display name
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 | |
/** | |
* Update my profile data before get BUC chat | |
* | |
* @param array $profile Get my profile data. | |
* @return array | |
*/ | |
function buc_update_my_profile_data( $profile ) { | |
$user_info = get_userdata( $profile['id'] ); | |
$first_name = $user_info->first_name; | |
$last_name = $user_info->last_name; | |
if ( $first_name ) { | |
$profile['fullname'] = $first_name . ' ' . $last_name; | |
} | |
return $profile; | |
} | |
add_filter( 'buc_before_get_my_profile', 'buc_update_my_profile_data', 10, 1 ); | |
/** | |
* Update friends profile data before get BUC chat | |
* | |
* @param array $profile Get friends profile data. | |
* @return array | |
*/ | |
function buc_update_friend_profile_data( $profile ) { | |
$user_info = get_userdata( $profile['id'] ); | |
$first_name = $user_info->first_name; | |
$last_name = $user_info->last_name; | |
if ( $first_name ) { | |
$profile['fullname'] = $first_name . ' ' . $last_name; | |
} | |
return $profile; | |
} | |
add_filter( 'buc_before_get_friends_profile', 'buc_update_friend_profile_data', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment