Advertisement
markmire

BP Follower Visibility

Jan 22nd, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. add_filter( 'bp_xprofile_get_visibility_levels', 'bpvis_customize_profile_visibility' );
  2. function bpvis_customize_profile_visibility( $allowed_visibilities ) {
  3. if( bp_is_active( 'follow' ) ) {
  4.  
  5. $allowed_visibilities['followers'] = array(
  6. 'id' => 'followers',
  7. 'label' => _x( 'My Followers', 'Visibility level setting', 'bp-extended-profile-visibility' )
  8. );
  9.  
  10. }
  11.  
  12. return $allowed_visibilities;
  13. }
  14.  
  15.  
  16.  
  17. add_filter( 'bp_xprofile_get_hidden_field_types_for_user', 'bpvis_get_hidden_visibility_types_for_user', 10, 3 );
  18.  
  19. function bpvis_get_hidden_visibility_types_for_user( $hidden_levels, $displayed_user_id, $current_user_id ) {
  20.  
  21. if( ( $displayed_user_id != $current_user_id ) && ! bpvis_user_is_follower( $displayed_user_id, $current_user_id ) && ! is_super_admin() ) {
  22.  
  23. $hidden_levels[] = 'followers';
  24.  
  25. }
  26.  
  27. return $hidden_levels;
  28.  
  29. }
  30.  
  31.  
  32.  
  33. function bpvis_get_followers( $user_id ) {
  34.  
  35. $followers = bpvis_get_followers( $user_id );
  36.  
  37. if( ! empty( $followers ) )
  38. return true;
  39.  
  40. return false;
  41.  
  42. }
  43.  
  44. function bpvis_get_followers( $user_id ) {
  45.  
  46. global $wpdb;
  47.  
  48. //members table
  49. $table = buddypress()->followers->table_name_members;
  50.  
  51. $query_user_followers = $wpdb->prepare( "SELECT follow_id FROM {$table} WHERE user_id = %d AND is_confirmed = %d ", $user_id, 1 );
  52.  
  53.  
  54. return $followers;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement