Advertisement
Guest User

MailChimp Integration & Ultimate Facebook Compatability Hack

a guest
Feb 18th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. if ( ! function_exists( 'is_plugin_active' ) )
  5.     include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  6.  
  7. if ( is_plugin_active( 'wpmu-dev-facebook/wpmu-dev-facebook.php' ) ) {
  8.     function mailchimp_ultimate_fb_remove_filters() {
  9.         global $mailchimp_sync;
  10.  
  11.         remove_action( 'wpmu_new_user', array( $mailchimp_sync, 'mailchimp_add_user' ) );
  12.         remove_action( 'user_register', array( $mailchimp_sync, 'mailchimp_add_user' ) );
  13.         remove_action( 'make_ham_user', array( $mailchimp_sync, 'mailchimp_add_user' ) );
  14.     }
  15.     add_action( 'init', 'mailchimp_ultimate_fb_remove_filters' );
  16.  
  17.     function mailchimp_ultimate_fb_add_user( $uid, $registration, $me ) {
  18.         global $mailchimp_sync;
  19.  
  20.         $user = get_userdata( $uid );
  21.         $user_arr = array(
  22.             'email' => $user->user_email,
  23.             'first_name' => $me['first_name'],
  24.             'last_name' => $me['last_name'],
  25.             'wdfb' => (object) array( 'registration' => $registration, 'me' => $me )
  26.         );
  27.        
  28.         $mailchimp_sync->mailchimp_add_user( $user_arr );
  29.     }
  30.     add_action( 'wdfb-user_registered-postprocess', 'mailchimp_ultimate_fb_add_user', 10, 3 );                                             
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement