Skip to:
Content
Pages
Categories
Search
Top
Bottom

Simple call to xprofiles data


  • allenweiss
    Participant

    @allenweiss

    I’m trying to get a handle on just how the data in xprofiles works and how to pull it out for my purpose. Maybe someone can help me on this easy task (and then i can learn to expand this out).

    I have 2 fields in xprofiles and simply want to grab that for a given user. Will this function work to do that? If so, where would I store this function in order to make use of the bp_get_field_data function that it relies on. It this is wrong, how should it be change?

    function get_user_realName(){

    $user[‘First Name’] = bp_get_field_data(‘First Name’, $site_members_template->member->ID);

    $user[‘Last Name’] = bp_get_field_data(‘Last Name’, $site_members_template->member->ID);

    echo $user[‘First Name’].’ ‘.$user[‘Last Name’];

    }

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

  • 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.


    peterverkooijen
    Participant

    @peterverkooijen

    Thanks for this code, allenweiss! I still have to sort this out in my project, after my current day job deadline. Not looking forward to it…

    I had started several threads about this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Simple call to xprofiles data’ is closed to new replies.
Skip to toolbar