BP_Registration_Compatibility

Class BP_Registration_Compatibility.

Defined (1)

The class is defined in the following location(s).

/includes/compatibility.php  
  1. class BP_Registration_Compatibility { 
  2.  
  3. /** 
  4. * Piece it all together. 
  5. */ 
  6. public function __construct() { 
  7. // WP FB AutoConnect. 
  8. global $jfb_name; 
  9.  
  10. if ( ! empty( $jfb_name ) ) { 
  11. add_action( 'wpfb_inserted_user', array( $this, 'wp_fb_autoconnect_compat' ) ); 
  12.  
  13. $this->buddypress_like(); 
  14. $this->buddypress_send_invites(); 
  15.  
  16. // Filter BuddyPress Docs capabilities. 
  17. add_filter( 'bp_docs_map_meta_caps', array( $this, 'bp_docs_map_meta_caps' ), 100, 4 ); 
  18.  
  19. /** 
  20. * Adds compatibility support for WP-FB-AutoConnect. 
  21. * http://wordpress.org/plugins/wp-fb-autoconnect/ 
  22. * @param array $fbuser Array hoding Facebook user data. 
  23. */ 
  24. function wp_fb_autoconnect_compat( $fbuser ) { 
  25.  
  26. $id = $fbuser['WP_ID']; 
  27.  
  28. // Hide activity created by new user 
  29. // $sql = 'UPDATE ' . $wpdb->base_prefix . 'bp_activity SET hide_sitewide = 1 WHERE user_id = %d'; 
  30. // $wpdb->query( $wpdb->prepare( $sql, $id ) ); 
  31. // email admin about new member request. 
  32. $user = get_userdata( $id ); 
  33.  
  34. bp_registration_options_send_admin_email( 
  35. array( 
  36. 'user_login' => $user->data->user_login,  
  37. 'user_email' => $user->data->user_email,  
  38. 'message' => sprintf( 
  39. __( '%s ( %s ) would like to become a member of your website. To accept or reject their request, please go to <a href="%s">%s</a>.', 'bp-registration-options' ),  
  40. $user->data->user_nicename,  
  41. $user->data->user_email,  
  42. admin_url( '/admin.php?page=bp_registration_options_member_requests' ),  
  43. admin_url( '/admin.php?page=bp_registration_options_member_requests' ) 
  44. ),  
  45. ); 
  46.  
  47. /** 
  48. * Adds compatibility support for BuddyPress Like. 
  49. * https://wordpress.org/plugins/buddypress-like/ 
  50. */ 
  51. function buddypress_like() { 
  52.  
  53. $user = get_current_user_id(); 
  54. $moderate = (bool) get_option( 'bprwg_moderate' ); 
  55.  
  56. if ( empty( $moderate ) || ! $moderate ) { 
  57. return; 
  58.  
  59. if ( ! bp_registration_get_moderation_status( $user ) ) { 
  60. return; 
  61.  
  62. remove_filter( 'bp_activity_entry_meta' , 'bp_like_button', 1000 ); 
  63. remove_filter( 'bp_activity_comment_options' , 'bp_like_button', 1000 ); 
  64. remove_action( 'bp_before_blog_single_post' , 'bp_like_button' , 1000 ); 
  65.  
  66. remove_action( 'bp_activity_filter_options' , 'bp_like_activity_filter' ); 
  67. remove_action( 'bp_group_activity_filter_options' , 'bp_like_activity_filter' ); 
  68. remove_action( 'bp_member_activity_filter_options' , 'bp_like_activity_filter' ); 
  69.  
  70. remove_action( 'bp_setup_nav', 'invite_anyone_setup_nav' ); 
  71.  
  72. /** 
  73. * Adds compatibility support for BuddyPress Invite Anyone. 
  74. * https://wordpress.org/plugins/invite-anyone/ 
  75. */ 
  76. function buddypress_send_invites() { 
  77.  
  78. $user = get_current_user_id(); 
  79. $moderate = (bool) get_option( 'bprwg_moderate' ); 
  80.  
  81. if ( empty( $moderate ) || ! $moderate ) { 
  82. return; 
  83.  
  84. if ( ! bp_registration_get_moderation_status( $user ) ) { 
  85. return; 
  86.  
  87. remove_action( 'bp_setup_nav', 'invite_anyone_setup_nav' ); 
  88.  
  89. /** 
  90. * Prevents moderated users from critical interactions with BP Docs 
  91. * @param array $caps Capabilities for meta capability. 
  92. * @param string $cap Capability name. 
  93. * @param int $user_id User id. 
  94. * @param mixed $args Arguments passed to map_meta_cap filter. 
  95. * @return array $caps Capabilities for meta capability 
  96. */ 
  97. public function bp_docs_map_meta_caps( $caps, $cap, $user_id, $args ) { 
  98.  
  99. $moderate = (bool) get_option( 'bprwg_moderate' ); 
  100. if ( empty( $moderate ) || ! $moderate ) { 
  101. return $caps; 
  102.  
  103. if ( ! bp_registration_get_moderation_status( $user_id ) ) { 
  104. return $caps; 
  105.  
  106. // Do not allow these actions. 
  107. switch ( $cap ) { 
  108. case 'bp_docs_create' : 
  109. case 'bp_docs_edit' : 
  110. case 'bp_docs_manage' : 
  111. case 'bp_docs_post_comments' : 
  112. $caps = array( 'do_not_allow' ); 
  113. break; 
  114.  
  115. return $caps;