# Email a Custom Address When a Site Is Created

> Sends a short notice with the new site's name, address and creator to an address you choose, in addition to WordPress's own network admin email.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: new-site, email, notifications
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-new-site-notify-email/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

$wpide_notify_to = 'team@example.com'; // Recipient(s).

add_action( 'wp_initialize_site', function ( $site, $args ) use ( $wpide_notify_to ) {
    $user  = ! empty( $args['user_id'] ) ? get_userdata( $args['user_id'] ) : wp_get_current_user();
    $title = ! empty( $args['title'] ) ? $args['title'] : $site->domain . $site->path;
    $url   = set_url_scheme( 'http://' . $site->domain . $site->path );

    $body = sprintf(
        "A new site was created on %1\$s.\n\nName: %2\$s\nAddress: %3\$s\nCreated by: %4\$s\nManage: %5\$s\n",
        get_network()->site_name,
        $title,
        $url,
        $user && $user->exists() ? $user->user_login . ' <' . $user->user_email . '>' : 'unknown',
        network_admin_url( 'site-info.php?id=' . (int) $site->blog_id )
    );

    wp_mail( $wpide_notify_to, sprintf( '[%s] New site: %s', get_network()->site_name, $title ), $body );
}, 300, 2 );
```

## Notes

Set $wpide_notify_to; separate several addresses with commas.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Email a Custom Address When a Site Is Created" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
