Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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