Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: calling specific profile fields individually


John James Jacoby
Keymaster

@johnjamesjacoby

Within the members loop, the problem is that you’re not feeding it any user_id to get the data for… Like I said above, without a user_id, it’s just looking for the $bp->displayed_user->id, which doesn’t exist because when you’re on a directory page, there is no displaued_user->id; you’re not looking at a member…

Within any member related loop, you will need to make a custom function for that loop and use the user_id available to you to spit out what you need…

Put this in your bp-custom.php… (haven’t tested this, wrote freehand, lookout for bugs)

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 );
}

Then use it like this on fields that need checking…

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

…or like this on fields that don’t…

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

Skip to toolbar