How to get a buddypress user profile link and a certain user profile field for the current post author?

I want to replace get_author_link() and get_the_author_meta($feld)

with something equivalent to point to the author of the current post Buddypress user profile page and retrieve a specific profile field from his Buddypress page

ie, I just want to show a link to the post user profile and a biography from one of his BP profile fields

I’m not sure which functions I should use for this… BuddyPress documentation is still not very clear unlike the WP Codex…

thanks

Solutions Collecting From Web of "How to get a buddypress user profile link and a certain user profile field for the current post author?"

For an author’s profile link, use

bp_core_get_user_domain( $user_id )

to get the URL, and

bp_core_get_userlink( $user_id )

to get an HTML link element, including display name.

For the xprofile data, use

xprofile_get_field_data( $field, $user_id )

$field can be either the name of the field (like ‘Biography’) or the numerical field id.

If you need to add it in comments:

    <?php
$author_id = get_comment(get_comment_ID())->user_id;
if (function_exists('bp_get_profile_field_data')) {
    $bp_name = bp_core_get_userlink( $author_id );
    $bp_location = bp_get_profile_field_data('field=Location&user_id='.$author_id);
    if ($bp_name) {
    echo '<div>'. $bp_name . '</div>';
    }
    if ($bp_location) {
    echo '<div class="authorinfo">'. $bp_location . '</div>';
    }
}
?>

I included a sample profile field ‘location’, which may be removed. This is for displaying a link to comment author’s Buddypress profile. It must be placed inside your comments loop, which will look something like:

foreach($comments as $comment)

It’s kind of a bit different, but since this thread appears first on Google, it might be usefull for someone else.

To get the current logged-in user profile link, just use bp_loggedin_user_domain()

Hope that helps.