Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get a profile field content for a specific user outside BP pages?

  • Avatar of kuching
    kuching
    Participant

    @substrato

    I want to display a BP custom user profile field called “Bio” in WordPress custom posts to display author’s biography.

    I can retrieve ID of the user with get_author().

    However, how do I retrive that specific field from his profile? what function should I use? should I query $bp? how?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Have you tried xprofile_get_field_data?

    `
    $bio = xprofile_get_field_data(‘Bio’, $user_id);
    `

    Not sure what you mean by ‘outside’ BP…

    If you can’t use xprofile_get_field_data,
    then a custom call to your database would work, but you’ll need to figure out the id of the Bio field.
    `
    $bio = $wpdb->get_var( “SELECT value FROM wp_bp_xprofile_data WHERE user_id = $user_id AND field_id = $field_id_for_bio” );
    `

    No, don’t make a direct SQL query. Use that function in the first example. :)

    Avatar of kuching
    kuching
    Participant

    @substrato

    oh thank you guys I used the function as advised, works :)

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

You must be logged in to reply to this topic.