Last active
January 25, 2020 11:47
-
-
Save KaineLabs/ff5ec524a3ac66ddaf058b9d342091de to your computer and use it in GitHub Desktop.
BUddypress Show Xprofile Field Data in The Profile Header Username.
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 | |
/** | |
* BUddypress Show Xprofile Field Data in The Profile Header Username. | |
*/ | |
function yzc_add_xprofile_field_data_in_profile_header( $name ) { | |
if ( bp_is_user() ) { | |
$field_data = xprofile_get_field_data( 'Age', bp_displayed_user_id() ); | |
if ( ! empty( $field_data ) ) { | |
return $name . ', <span class="bp-user-age">' . $field_data . '</span>'; | |
} | |
} | |
return $name; | |
} | |
add_action( 'bp_get_displayed_user_mentionname', 'yzc_add_xprofile_field_data_in_profile_header' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment