wp_new_blog_notification( string $blog_title, string $blog_url, int $user_id, string $password )
- Since
- 2.1.0
- Source
wp-admin/includes/upgrade.php:575
Description
Sends an email to the new administrator that the installation is complete and provides them with a record of their login credentials.
Compatibility
- WordPress
- since 2.1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$blog_titlestring- Site title.
$blog_urlstring- Site URL.
$user_idint- Administrator's user ID.
$passwordstring- Administrator's password. Note that a placeholder message is usually passed instead of the actual password.
Performance profile
How much work a call to wp_new_blog_notification() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Expensive
- Scaling
- Constant
- Instructions
- 56
- Plugin surface
- 1 hook
- Called by
- 1
Sends mail via wp_mail().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 56.
Third-party callbacks on 'wp_installed_email' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - mailsends mail
wp_mail()called directly
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_new_blog_notification() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 56 | wp_login_url(), __(), sprintf(), __(), apply_filters(), wp_mail() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 56 instructions, 56 executed per call, 0 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while wp_new_blog_notification() runs, in this order:
- apply_filters( wp_installed_email )filterline 638 (+63 into the body)
Filters the contents of the email sent to the site administrator when WordPress is installed.
Uses · 5
- wp_login_url()Retrieves the login URL.
- __()Retrieves the translation of $text.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_mail()Sends an email, similar to PHP's mail function.
- WP_User::__construct()Constructor.
Used by · 1
- wp_install()Installs the site.
Source code
function wp_new_blog_notification( $blog_title, $blog_url, $user_id, #[\SensitiveParameter] $password ) { $user = new WP_User( $user_id ); $email = $user->user_email; $name = $user->user_login; $login_url = wp_login_url(); $message = sprintf( /* translators: New site notification email. 1: New site URL, 2: User login, 3: User password or password reset link, 4: Login URL. */ __( 'Your new WordPress site has been successfully set up at: %1$s You can log in to the administrator account with the following information: Username: %2$sPassword: %3$sLog in here: %4$s We hope you enjoy your new site. Thanks! --The WordPress Teamhttps://wordpress.org/' ), $blog_url, $name, $password, $login_url ); $installed_email = array( 'to' => $email, 'subject' => __( 'New WordPress Site' ), 'message' => $message, 'headers' => '', ); /** * Filters the contents of the email sent to the site administrator when WordPress is installed. * * @since 5.6.0 * * @param array $installed_email { * Used to build wp_mail(). * * @type string $to The email address of the recipient. * @type string $subject The subject of the email. * @type string $message The content of the email. * @type string $headers Headers. * } * @param WP_User $user The site administrator user object. * @param string $blog_title The site title. * @param string $blog_url The site URL. * @param string $password The site administrator's password. Note that a placeholder message * is usually passed instead of the user's actual password. */ $installed_email = apply_filters( 'wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password ); wp_mail( $installed_email['to'], $installed_email['subject'], $installed_email['message'], $installed_email['headers'] ); }Changelog
Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/upgrade.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.