MC4WP_bbPress_Integration

The MailChimp for WordPress Lite MC4WP bbPress Integration class.

Defined (1)

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

/includes/integrations/class-bbpress.php  
  1. class MC4WP_bbPress_Integration extends MC4WP_User_Integration { 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. protected $type = 'bbpress_forms'; 
  7.  
  8. /** 
  9. * Constructor 
  10. */ 
  11. public function __construct() { 
  12.  
  13. parent::__construct(); 
  14.  
  15. add_action( 'bbp_theme_after_topic_form_subscriptions', array( $this, 'output_checkbox' ), 10 ); 
  16. add_action( 'bbp_theme_after_reply_form_subscription', array( $this, 'output_checkbox' ), 10 ); 
  17. add_action( 'bbp_theme_anonymous_form_extras_bottom', array( $this, 'output_checkbox' ), 10 ); 
  18. add_action( 'bbp_new_topic', array( $this, 'subscribe_from_bbpress_new_topic' ), 10, 4 ); 
  19. add_action( 'bbp_new_reply', array( $this, 'subscribe_from_bbpress_new_reply' ), 10, 5 ); 
  20.  
  21. /** 
  22. * @param array $anonymous_data 
  23. * @param int $user_id 
  24. * @param string $trigger 
  25. * @return boolean 
  26. */ 
  27. public function subscribe_from_bbpress( $anonymous_data, $user_id, $trigger ) { 
  28.  
  29. if( $this->is_spam() ) { 
  30. return false; 
  31.  
  32. if ( $this->checkbox_was_checked() === false ) { 
  33. return false; 
  34.  
  35. if ( $anonymous_data ) { 
  36.  
  37. $email = $anonymous_data['bbp_anonymous_email']; 
  38. $merge_vars = array( 
  39. 'NAME' => $anonymous_data['bbp_anonymous_name'],  
  40. ); 
  41.  
  42. } elseif ( $user_id ) { 
  43.  
  44. $user = get_userdata( $user_id ); 
  45. if( ! $user ) { 
  46. return false; 
  47.  
  48. $email = $user->user_email; 
  49. $merge_vars = $this->user_merge_vars( $user ); 
  50.  
  51. } else { 
  52. return false; 
  53.  
  54. return $this->subscribe( $email, $merge_vars, $trigger ); 
  55.  
  56. public function subscribe_from_bbpress_new_topic( $topic_id, $forum_id, $anonymous_data, $topic_author_id ) { 
  57. return $this->subscribe_from_bbpress( $anonymous_data, $topic_author_id, 'bbpress_new_topic' ); 
  58.  
  59. public function subscribe_from_bbpress_new_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id ) { 
  60. return $this->subscribe_from_bbpress( $anonymous_data, $reply_author_id, 'bbpress_new_reply' ); 
  61.