From f6005f2e9d31a1846ab59103cd5385a3a74ea08e Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Mon, 14 Apr 2025 15:45:07 +0300 Subject: [PATCH] Prevent admin notifications and refine user registration logic Updated the registration process to avoid sending notifications for admin-created users. Simplified and clarified user status handling, ensuring consistent behavior across frontend and admin actions. --- includes/core/um-actions-register.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index bea94795..0dd11a1b 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -113,7 +113,8 @@ add_action( 'um_user_register', 'um_after_insert_user', 1, 3 ); * @param $user_id */ function um_send_registration_notification( $user_id ) { - if ( is_admin() && UM()->options()->get( 'auto_user_approve' ) ) { + if ( is_admin() ) { + // Don't send email notifications to administrators about new user registration, because the user was created from wp-admin. return; } @@ -141,11 +142,10 @@ add_action( 'um_registration_complete', 'um_send_registration_notification' ); * @param null|array $form_data */ function um_check_user_status( $user_id, $args, $form_data = null ) { - $registration_status = um_user( 'status' ); - if ( ( is_null( $form_data ) || is_admin() ) && UM()->options()->get( 'auto_user_approve' ) ) { - UM()->common()->users()->set_status( $user_id, 'approved' ); - return; + $registration_status = 'approved'; + } else { + $registration_status = um_user( 'status' ); } /** @@ -182,6 +182,7 @@ function um_check_user_status( $user_id, $args, $form_data = null ) { if ( is_null( $form_data ) || is_admin() ) { return; } + // Code below is running only for registration from the frontend forms. /** * Fires after complete UM user registration. Only for the frontend action which is run before autologin and redirects.