From b709bb39146a27227fdde661d3712495f6f49739 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Sun, 1 Apr 2018 15:45:25 +0300 Subject: [PATCH] - update account email notification; --- includes/class-config.php | 13 ++++++++++ includes/core/um-actions-account.php | 27 ++++++++++++++++++++- templates/email/changedaccount_email.php | 30 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 templates/email/changedaccount_email.php diff --git a/includes/class-config.php b/includes/class-config.php index d1fb3243..0650cc52 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -427,6 +427,19 @@ if ( ! class_exists( 'um\Config' ) ) { 'recipient' => 'user', 'default_active' => true ), + 'changedaccount_email' => array( + 'key' => 'changedaccount_email', + 'title' => __( 'Account Updated Email','ultimate-member' ), + 'subject' => 'Your account at {site_name} was updated', + 'body' => 'Hi {display_name},

' . + 'You recently updated your {site_name} account.

' . + 'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}

' . + 'Thanks,
' . + '{site_name}', + 'description' => __('Whether to send the user an email when he updated their account','ultimate-member'), + 'recipient' => 'user', + 'default_active'=> true + ), 'notification_new_user' => array( 'key' => 'notification_new_user', 'title' => __( 'New User Notification','ultimate-member' ), diff --git a/includes/core/um-actions-account.php b/includes/core/um-actions-account.php index aa21b4ad..af9c93b4 100644 --- a/includes/core/um-actions-account.php +++ b/includes/core/um-actions-account.php @@ -416,4 +416,29 @@ add_action( 'wp_footer', 'um_account_secure_registered_fields' ); function um_after_user_account_updated_permalink( $user_id, $changed ) { UM()->user()->generate_profile_slug( $user_id ); } -add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 ); \ No newline at end of file +add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 ); + + +/** + * Update Account Email Notification + * + * @param $user_id + * @param $changed + */ +function um_account_updated_notification( $user_id, $changed ) { + um_fetch_user( $user_id ); + UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' ); +} +add_action( 'um_after_user_account_updated', 'um_account_updated_notification', 20, 2 ); + + +/** + * Disable WP native email notification when change email on user account + * + * @param $user_id + * @param $changed + */ +function um_disable_native_email_notificatiion( $changed, $user_id ) { + add_filter( 'send_email_change_email', '__return_false' ); +} +add_action( 'um_account_pre_update_profile', 'um_disable_native_email_notificatiion', 10, 2 ); \ No newline at end of file diff --git a/templates/email/changedaccount_email.php b/templates/email/changedaccount_email.php new file mode 100644 index 00000000..519587e5 --- /dev/null +++ b/templates/email/changedaccount_email.php @@ -0,0 +1,30 @@ + + +
+ +
+
{site_name}
+ +
+
+ +
+ +
You recently updated your account.
+ +
Go to your Account
+ +
If you did not make this change and believe your account has been compromised, please contact us ASAP.
+ +
+ +
+ +
Thank you!
+
The {site_name} Team
+ +
+ +
\ No newline at end of file