Last active
October 6, 2023 14:01
-
-
Save yuriinalivaiko/ba62ffac9f58b7eae8e60fbbfc4457b4 to your computer and use it in GitHub Desktop.
This code triggers sending the "New User Notification" email notification. Example 1 - after the profile update. Example 2 - after create an account during checkout (WooCommerce).
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 | |
// Send the "New User Notification" email when profile is updated. | |
add_action( 'um_user_after_updating_profile', function( $to_update, $user_id, $args ) { | |
$GLOBALS['um_temp_submitted'] = isset( $args['submitted'] ) ? $args['submitted'] : $args; | |
function um_user_after_updating_profile_submitted( $value ) { | |
return $GLOBALS['um_temp_submitted']; | |
} | |
function um_user_after_updating_profile_timestamp( $value ) { | |
return time(); | |
} | |
add_filter( 'um_profile_submitted__filter', 'um_user_after_updating_profile_submitted' ); | |
add_filter( 'um_profile_timestamp_empty__filter', 'um_user_after_updating_profile_timestamp' ); | |
um_send_registration_notification( $user_id ); | |
remove_filter( 'um_profile_submitted__filter', 'um_user_after_updating_profile_submitted' ); | |
remove_filter( 'um_profile_timestamp_empty__filter', 'um_user_after_updating_profile_timestamp' ); | |
}, 20, 3 ); |
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 | |
// Send the "New User Notification" email when a new user is registered via WooCommerce. | |
add_action( 'woocommerce_created_customer', function( $customer_id, $new_customer_data, $password_generated ) { | |
if ( function_exists( 'um_send_registration_notification' ) ) { | |
add_filter( 'um_email_send_message_content', function( $message, $slug, $args ) { | |
if ( 'notification_new_user' === $slug ) { | |
$search = '{submitted_registration}'; | |
$replace = '<p>Registered via WooCommerce. See "New order" email for details.</p>'; | |
$message = str_replace( $search, $replace, $message ); | |
} | |
return $message; | |
}, 10, 3 ); | |
um_send_registration_notification( $customer_id ); | |
} | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment