Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Simple call to xprofiles data


allenweiss
Participant

@allenweiss

I figured out a solution to my problem and thought I’d post it here in case others have the same problem I have. I have a community for professionals who when the sign up have the option to use their username or their first and last names (most choose to use their first and last names) in the community. BP doesn’t handle this option at all and all lists (e.g., members) show only the username (user_nicename or display_name), so I had to write a function to pull the first and last names, when somebody used this. Here is the function, which I placed in the mu-plugins folder:

function get_user_realName(){

global $site_members_template;

$u[‘1’]=xprofile_get_field_data(‘First Name’,$site_members_template->member->id);

$u[‘2’]=xprofile_get_field_data(‘Last Name’,$site_members_template->member->id);

if ( empty( $u[‘1’] ) ) {

$temp=bp_user_fullname();

if ( empty( $temp) )

echo bp_the_site_member_name();

else

echo bp_user_fullname();

} else {

echo $u[‘1′].’ ‘.$u[‘2’];

}

}

I’m not saying this is pretty, but it gets the job done until BP makes it easier for members to choose how they want to be known in the community.

Skip to toolbar