Tagged: xprofile
I’m adding new fields programmatically. How do I set the default visibility?
$field_id = xprofile_insert_field([ 'field_group_id' => $group->id, 'type' => 'textbox', 'name' => 'Admins Only Field', 'is_required' => false, 'can_delete' => true, 'field_order' => 3, 'description' => "Enter something in this field that only you can see." ]);
After getting the
$field_id
, I can load all the users and set their individual visibility toadminsonly
usingxprofile_set_field_visibility_level
— but that doesn’t change it on the Edit Field info.Hi Matt,
Welcome to BuddyDev.
You are setting the visibility for the data using the ‘xprofile_set_field_visibility_level’. Please try setting it for field using the followingbp_xprofile_update_field_meta( $field_id, 'default_visibility', 'adminsonly' ); bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', 'disabled' );
After you get the field id. That should do it.
Regards
Brajesh
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘ [Resolved] Set default visibility for new profile field programmatically’ is closed to new replies.
This topic is: resolved