newuser_notify_siteadmin() WordPress Function

The newuser_notify_siteadmin() function is used to notify the site administrator about a new user registration. This function is triggered when a new user registers on the site. It sends an email to the administrator with the new user's information.

newuser_notify_siteadmin( int $user_id ) #

Notifies the network admin that a new user has been activated.


Description

Filter ‘newuser_notify_siteadmin’ to change the content of the notification email.


Top ↑

Parameters

$user_id

(int)(Required)The new user's ID.


Top ↑

Return

(bool)


Top ↑

Source

File: wp-includes/ms-functions.php

1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
function newuser_notify_siteadmin( $user_id ) {
    if ( 'yes' !== get_site_option( 'registrationnotification' ) ) {
        return false;
    }
 
    $email = get_site_option( 'admin_email' );
 
    if ( is_email( $email ) == false ) {
        return false;
    }
 
    $user = get_userdata( $user_id );
 
    $options_site_url = esc_url( network_admin_url( 'settings.php' ) );
 
    $msg = sprintf(
        /* translators: New user notification email. 1: User login, 2: User IP address, 3: URL to Network Settings screen. */
        __(
            'New User: %1$s
Remote IP address: %2$s
 
Disable these notifications: %3$s'
        ),
        $user->user_login,
        wp_unslash( $_SERVER['REMOTE_ADDR'] ),
        $options_site_url
    );
 
    /**
     * Filters the message body of the new user activation email sent
     * to the network administrator.
     *
     * @since MU (3.0.0)
     *
     * @param string  $msg  Email body.
     * @param WP_User $user WP_User instance of the new user.
     */
    $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
 
    /* translators: New user notification email subject. %s: User login. */
    wp_mail( $email, sprintf( __( 'New User Registration: %s' ), $user->user_login ), $msg );
 
    return true;
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More