Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Display single xprofile fields


peterverkooijen
Participant

@peterverkooijen

I got this solution here earlier. This in functions.php or bp_custom.php:

function bp_custom_member_list_xprofile_data( $field ) {
echo bp_custom_get_member_list_xprofile_data( $field );
}
function bp_custom_get_member_list_xprofile_data( $field ) {
global $site_members_template;
return xprofile_get_field_data( $field, $site_members_template->member->id );
}

And then this in the template:

<?php if ( $company = bp_custom_get_member_list_xprofile_data('Company') ) : ?>
<p><?php echo $company ?></p>
<?php endif; ?>

I didn’t come up with this myself. Forgot who deserves the credit…

EDIT:

BTW, this seems to work as well:

<p><?php echo bp_custom_get_member_list_xprofile_data('Company') ?></p>

Or am I missing something?

EDIT2:

Or further cleaned up:

function custom_xprofile( $field ) {
echo bp_custom_get_member_list_xprofile_data( $field );
}
function bp_custom_get_member_list_xprofile_data( $field ) {
global $site_members_template;
return xprofile_get_field_data( $field, $site_members_template->member->id );
}

In the template:

<p><?php custom_xprofile('Company') ?></p>

Skip to toolbar