Hmm, I think xprofile_get_field_data()
might need to be altered in order to add logged-in visibility level checks.
Can you create a ticket at https://trac.buddypress.org/newticket so someone can take a look at this later on?
@r-a-y
Any reason not to use bp_xprofile_get_hidden_fields_for_user() ?
Thanks guys. bp_xprofile_get_hidden_fields_for_user() was the thing that I needed! This is 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; ?>
I have a slightly related question – the above works in terms of displaying a field, but it doesn’t help if you just want to know the specific level of privacy a user has attached to a field.
For example I want a user to be able to trigger an action themselves (ie they are the logged in user), which would provide only their xprofile data which is set to ‘public’. It would be really useful to be able to directly query the profile visibility, not to the current user, but get the actual value.
get_profile_field_visibility('The Field Label', $the_user_id )
Is this possible?