Displaying BuddyPress Extended Profile (xProfile) Data

Using bp_get_profile_data(), extended profile field data can be retrieved to display it in theme / template file. At the minimum, this function requires user_id and field (id or name). Further to respect the visibility setting of the field, use it in combination with bp_xprofile_get_hidden_fields_for_user

Getting Extended Profile Data

Using bp_get_profile_data(),  extended profile field data can be retrieved to display it in theme / template file. At the minimum, this function requires user_id and field (id or name). It can be used like :

bp_get_profile_field_data($args)

like

Displaying Fields depending upon Visibility Setting

But problem here is, this function returns all the profile data whenever available without respecting the visibility settings of a particular profile field.

To overcome this problem, following function can used:

bp_xprofile_get_hidden_fields_for_user($displayed_user_id, $current_user_id)

The bp_xprofile_get_hidden_fields_for_user returns IDs of all profile fields which are hidden for current user.

So, complete code will be: