Skip to content

Instantly share code, notes, and snippets.

@imanispatel
Created November 18, 2020 07:42
Show Gist options
  • Save imanispatel/92fe163e3b6e20b7619a8a3d73ea7a68 to your computer and use it in GitHub Desktop.
Save imanispatel/92fe163e3b6e20b7619a8a3d73ea7a68 to your computer and use it in GitHub Desktop.
Change my and friends profile data example: change user display name
<?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