-
Notifications
You must be signed in to change notification settings - Fork 38
Add (My Followers) profile visibility option
Here's a guide on how to add a new visibility option called 'My Followers' using the BuddyPress Follow plugin.
/* My Followers - BuddyPress Profile Visibility Option */
function custom_modify_visibility_levels($allowed_visibilities) { if (function_exists('bp_follow_is_following')) { $allowed_visibilities['followers'] = array( 'id' => 'followers', 'label' => __('My Followers', 'buddypress') ); } return $allowed_visibilities; } add_filter('bp_xprofile_get_visibility_levels', 'custom_modify_visibility_levels');
/* Adjust visibility based on followers */
function custom_get_hidden_visibility_types_for_user($hidden_levels, $displayed_user_id, $current_user_id) { if ($displayed_user_id != $current_user_id && !bp_follow_is_following(array('leader_id' => $displayed_user_id, 'follower_id' => $current_user_id)) && !is_super_admin()) { $hidden_levels[] = 'followers'; // Hide profile field with 'My Followers' visibility level for the user } return $hidden_levels; } add_filter('bp_xprofile_get_hidden_field_types_for_user', 'custom_get_hidden_visibility_types_for_user', 10, 3);