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 use the following code to get a custom BuddyPress Xprofile field:

<?php if($field = bp_get_profile_field_data('field=field_name')) : ?>
<p><?php echo $field; ?></p>
<?php endif; ?>

But how can I check if the current viewer has the permission to view the field (from the visibility setting who the user can set)?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I found the answer to this question with support from the members from the BuddyPress forum. The function that I needed was xprofile_get_field_data().

Here my code:

<?php $hidden_fields = bp_xprofile_get_hidden_fields_for_user(); ?>
<?php if(xprofile_get_field_data('field_name') && !in_array(xprofile_get_field_id_from_name('field_name'), $hidden_fields)) : ?>
<p><?php echo xprofile_get_field_data ('field_name'); ?></p>
<?php endif; ?>
share|improve this answer
add comment

Your Answer


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.