Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'bp_xprofile_get_visibility_levels', 'bpvis_customize_profile_visibility' );
- function bpvis_customize_profile_visibility( $allowed_visibilities ) {
- if( bp_is_active( 'follow' ) ) {
- $allowed_visibilities['followers'] = array(
- 'id' => 'followers',
- 'label' => _x( 'My Followers', 'Visibility level setting', 'bp-extended-profile-visibility' )
- );
- }
- return $allowed_visibilities;
- }
- add_filter( 'bp_xprofile_get_hidden_field_types_for_user', 'bpvis_get_hidden_visibility_types_for_user', 10, 3 );
- function bpvis_get_hidden_visibility_types_for_user( $hidden_levels, $displayed_user_id, $current_user_id ) {
- if( ( $displayed_user_id != $current_user_id ) && ! bpvis_user_is_follower( $displayed_user_id, $current_user_id ) && ! is_super_admin() ) {
- $hidden_levels[] = 'followers';
- }
- return $hidden_levels;
- }
- function bpvis_get_followers( $user_id ) {
- $followers = bpvis_get_followers( $user_id );
- if( ! empty( $followers ) )
- return true;
- return false;
- }
- function bpvis_get_followers( $user_id ) {
- global $wpdb;
- //members table
- $table = buddypress()->followers->table_name_members;
- $query_user_followers = $wpdb->prepare( "SELECT follow_id FROM {$table} WHERE user_id = %d AND is_confirmed = %d ", $user_id, 1 );
- return $followers;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement