Tagged: xprofile field
Hi Abhist,
Welcome to BuddyDev forums.Thank you for the question. Here are my answers.
1. The profile field visibility is a BuddyPress core feature and has nothing to do with teh xprofile cusotm field types plugin.
2. You can not change the visibility for a user. It is saved for each field of the user. So, if you have 20 fields, you will need to update it for all the 20 fields.
Here is the function which is used to set it
xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
Where $field_id is the numeric xprofile field id.
$user_id is the numric id of the user in context.
$visibility_level is a string which is one of the registered visibility levels(e.g ‘loggedin’).Hope that helps.
PS:- The visibility setting is stored in user meta, so if you wnat to avoid too many queries, you can directly update the user meta key ‘bp_xprofile_visibility_levels’ with an associative array containing field id as key and its visibility as the value.
Regards
Brajesh
The topic ‘ [Resolved] Xrofile field visibility change by php function’ is closed to new replies.