Nicename is not a BuddyPress field.
It is a field in the WP users table.
You need to use a WP function like:
https://codex.wordpress.org/Function_Reference/get_userdata
Thank you @shanebp !! I check that link and tried multiple options for around an hour but I’m quite lost.
How can I apply that usernice name into this code?
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’ );
Thanks again 🙂
Please use the code button
when posting code.
$user_info = get_userdata( bp_displayed_user_id() );
$nicename = $user_info->user_nicename;
Hi again,
So I suppose that I need to place that two lines of code after add_action, right?
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( ‘<strong>$user_info = get_userdata( bp_displayed_user_id() );
$nicename = $user_info->user_nicename;</strong>
’, ‘yzc_add_xprofile_field_data_in_profile_header’ );
Cash Home Buyers Pro is a based home buying service that provides quick sale solutions to those who need to sell their house fast. We buy houses San Jose