WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 11 down vote accepted

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.

share|improve this answer

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)
share|improve this answer

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.

share|improve this answer

protected by Pieter Goosen Dec 29 '15 at 9:05

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.