How to disable new user welcome email for admins
-
Hello,
Your plugin does not allow this code below to work
// Disable new user registration email in WordPress for admin users only function disable_send_new_user_notifications($user_id, $notify = 'user') { // Check if user role is administrator $user_role = get_user_meta($user_id, 'wp_capabilities', true); if (isset($user_role['administrator'])) { // User is an administrator, skip sending notification return; } if (empty($notify) || 'admin' === $notify) { return; } elseif ('both' === $notify) { // Send new users the email but not the admin. $notify = 'user'; } wp_send_new_user_notifications($user_id, $notify); } // Disable default email notifications add_action('init', function () { remove_action('register_new_user', 'wp_send_new_user_notifications'); remove_action('edit_user_created_user', 'wp_send_new_user_notifications'); // For BuddyPress remove_action('bp_core_activated_user', 'wp_send_new_user_notifications'); // For WooCommerce remove_action('woocommerce_created_customer', 'wp_send_new_user_notifications'); }); // Replace default notifications with custom function add_action('register_new_user', 'disable_send_new_user_notifications'); add_action('edit_user_created_user', 'disable_send_new_user_notifications', 10, 2); // For BuddyPress add_action('bp_core_activated_user', 'disable_send_new_user_notifications'); // For WooCommerce add_action('woocommerce_created_customer', 'disable_send_new_user_notifications');
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘How to disable new user welcome email for admins’ is closed to new replies.