Created
February 24, 2018 03:37
-
-
Save wpmudev-sls/3165969966f5de963eb51cc8defe4cb8 to your computer and use it in GitHub Desktop.
EventsPlus Change New Registration Notification Email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: EventsPlus Change New Registration Notification Email | |
* Plugin URI: https://premium.wpmudev.org/ | |
* Description: Change the email of receiving new registration email in events plus plugin | |
* Author: Ariful Islam @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org/profile/itsarifulislam | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
if ( ! class_exists( 'EventsPlusChangeRegistrationNotificationEmail' ) ) { | |
class EventsPlusChangeRegistrationNotificationEmail { | |
private static $_instance = null; | |
private $actions = array(); | |
private $send_to = 'test@gmail.com'; // Change the email | |
public static function get_instance() { | |
if ( is_null( self::$_instance ) ) { | |
self::$_instance = new EventsPlusChangeRegistrationNotificationEmail(); | |
} | |
return self::$_instance; | |
} | |
private function __construct() { | |
$this->actions = array( | |
'wp_ajax_nopriv_eab_facebook_login', | |
'wp_ajax_nopriv_eab_twitter_login', | |
'wp_ajax_nopriv_eab_google_login', | |
'wp_ajax_nopriv_eab_google_plus_login', | |
'wp_ajax_nopriv_eab_wordpress_register' | |
); | |
$this->populate_actions(); | |
} | |
public function populate_actions() { | |
foreach ( $this->actions as $action ) { | |
add_action( $action, array( $this, 'wp_new_user_notification_email_admin_filter' ) ); | |
} | |
} | |
public function wp_new_user_notification_email_admin_filter() { | |
add_filter( 'wp_new_user_notification_email_admin', array( $this, 'wp_new_user_notification_email_admin_callback' ), 10, 1 ); | |
} | |
public function wp_new_user_notification_email_admin_callback( $wp_new_user_notification_email ) { | |
remove_filter( 'wp_new_user_notification_email_admin', array( $this, 'wp_new_user_notification_email_admin_callback' ) ); | |
if ( !empty( $this->send_to ) ) { | |
$wp_new_user_notification_email['to'] = $this->send_to; | |
} | |
return $wp_new_user_notification_email; | |
} | |
} | |
function render_eventsPlus_change_registration_notification_email(){ | |
$GLOBALS['EventsPlusChangeRegistrationNotificationEmail'] = EventsPlusChangeRegistrationNotificationEmail::get_instance(); | |
} | |
} | |
render_eventsPlus_change_registration_notification_email(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment