Home / Admin / Desactivar avisos nuevos usuarios
Duplicate Snippet

Embed Snippet on Your Site

Desactivar avisos nuevos usuarios

Code Preview
php
<?php
<?php
function wpcode_send_new_user_notifications( $user_id, $notify = 'user' ) {
    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 );
}
 
add_action(
    'init',
    function () {
        // Disable default email notifications.
        remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
        remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications' );
 
        // Replace with custom function that only sends to user.
        add_action( 'register_new_user', 'wpcode_send_new_user_notifications' );
        add_action( 'edit_user_created_user', 'wpcode_send_new_user_notifications', 10, 2 );
    }
);

Comments

Add a Comment