wp_new_user_notification( int $user_id, mixed $deprecated = null, string $notify = '' )
- Since
- 2.0.0, 4.3.0, 4.3.1, 4.6.0
- Source
wp-includes/pluggable.php:2276
Description
A new user registration notification is also sent to admin email.
Compatibility
- WordPress
- since 4.6.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
$user_idint- User ID.
$deprecatedmixedoptional- Not used.Default:
null $notifystringoptional- Type of notification that should happen. Accepts 'admin' or an empty string (admin only), 'user', or 'both' (admin and user). Default empty.Default:
''
Performance profile
How much work a call to wp_new_user_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
- 8–204
- Plugin surface
- 4 hooks
- 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, depending on the branch taken. The body compiles to 213.
Third-party callbacks on 'wp_send_new_user_notification_to_admin', 'wp_new_user_notification_email_admin', 'wp_send_new_user_notification_to_user' 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
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - querycontent query
get_user_by()called directly - mailsends mail
wp_mail()called directly - cacheobject cache
wp_cache_get()one call below wp_new_user_notification() - serializeserialisation
maybe_unserialize()one call below wp_new_user_notification()
Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 42 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_new_user_notification() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$deprecated === null && !$notify | 8 | none |
$deprecated !== null && !$notify | 12 | _deprecated_argument() |
$deprecated === null && $notify | 36–44 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters() |
$deprecated !== null && $notify | 40–48 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters() |
$deprecated === null && $notify && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 48–52 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated !== null && $notify && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 52–56 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated === null && $notify && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 109–113 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated === null && $notify && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 111–115 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated !== null && $notify && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 113–117 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated !== null && $notify && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 115–119 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true | 120–126 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true | 121–127 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters() |
30 further outcomes, up to 204 instructions
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true | 122–128 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true | 123–129 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true | 124–130 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true | 125–131 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true | 126–132 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true | 127–133 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 132–134 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 133–135 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 134–136 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 135–137 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 136–138 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 137–139 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 138–140 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && is_wp_error() | 139–141 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 193–195 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 194–196 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 195–197 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 195–197 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 196–198 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 196–198 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 197–199 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 197–199 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 198–200 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated === null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 198–200 | get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 199–201 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 199–201 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 200–202 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 200–202 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 201–203 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), get_locale(), switch_to_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
$deprecated !== null && $notify && $notify !== "user" && $send_notification_to_admin === true && $notify !== "admin" && $send_notification_to_user is not null, false, long, double, string, array, object, resource && !is_wp_error() | 202–204 | _deprecated_argument(), get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), get_option(), get_user_by(), switch_to_user_locale(), __(), sprintf(), __(), sprintf(), __(), sprintf(), get_option(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale(), apply_filters(), get_password_reset_key(), is_wp_error(), switch_to_user_locale(), __(), rawurlencode(), network_site_url(), __(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 213 instructions, 8–204 executed per call, 12 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 · 4
4 hooks fire while wp_new_user_notification() runs, in this order:
- apply_filters( wp_send_new_user_notification_to_admin )filterline 2302 (+26 into the body)
Filters whether the admin is notified of a new user registration.
- apply_filters( wp_new_user_notification_email_admin )filterline 2345 (+69 into the body)
Filters the contents of the new user notification email sent to the site admin.
- apply_filters( wp_send_new_user_notification_to_user )filterline 2367 (+91 into the body)
Filters whether the user is notified of their new user registration.
- apply_filters( wp_new_user_notification_email )filterline 2416 (+140 into the body)
Filters the contents of the new user notification email sent to the new user.
Uses · 15
- _deprecated_argument()Marks a function argument as deprecated and inform when it has been used.
- get_userdata()Retrieves user info by user ID.
- wp_specialchars_decode()Converts a number of HTML entities into their special characters.
- get_option()Retrieves an option value based on an option name.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_user_by()Retrieves user info by a given field.
- switch_to_user_locale()Switches the translations according to the given user's locale.
- switch_to_locale()Switches the translations according to the given locale.
- get_locale()Retrieves the current locale.
- __()Retrieves the translation of $text.
- wp_mail()Sends an email, similar to PHP's mail function.
- restore_previous_locale()Restores the translations according to the previous locale.
Show all 15
- get_password_reset_key()Creates, stores, then returns a password reset key for user.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- network_site_url()Retrieves the site URL for the current network.
Used by · 1
- wp_send_new_user_notifications()Initiates email notifications related to the creation of new users.
Source code
function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) { if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '4.3.1' ); } // Accepts only 'user', 'admin' , 'both' or default '' as $notify. if ( ! in_array( $notify, array( 'user', 'admin', 'both', '' ), true ) ) { return; } $user = get_userdata( $user_id ); /* * The blogname option is escaped with esc_html() on the way into the database in sanitize_option(). * We want to reverse this for the plain text arena of emails. */ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); /** * Filters whether the admin is notified of a new user registration. * * @since 6.1.0 * * @param bool $send Whether to send the email. Default true. * @param WP_User $user User object for new user. */ $send_notification_to_admin = apply_filters( 'wp_send_new_user_notification_to_admin', true, $user ); if ( 'user' !== $notify && true === $send_notification_to_admin ) { $admin_user = get_user_by( 'email', get_option( 'admin_email' ) ); if ( $admin_user ) { $switched_locale = switch_to_user_locale( $admin_user->ID ); } else { $switched_locale = switch_to_locale( get_locale() ); } /* translators: %s: Site title. */ $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n"; /* translators: %s: User login. */ $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n"; /* translators: %s: User email address. */ $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n"; $wp_new_user_notification_email_admin = array( 'to' => get_option( 'admin_email' ), /* translators: New user registration notification email subject. %s: Site title. */ 'subject' => __( '[%s] New User Registration' ), 'message' => $message, 'headers' => '', ); /** * Filters the contents of the new user notification email sent to the site admin. * * @since 4.9.0 * * @param array $wp_new_user_notification_email_admin { * Used to build wp_mail(). * * @type string $to The intended recipient - site admin email address. * @type string $subject The subject of the email. * @type string $message The body of the email. * @type string $headers The headers of the email. * } * @param WP_User $user User object for new user. * @param string $blogname The site title. */ $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname ); wp_mail( $wp_new_user_notification_email_admin['to'], wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ), $wp_new_user_notification_email_admin['message'], $wp_new_user_notification_email_admin['headers'] ); if ( $switched_locale ) { restore_previous_locale();Changelog
Introduced in 2.0.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$deprecated retyped from null to mixed.verified against source$notify parameter accepts 'user' for sending notification only to the user created.from the docblock$plaintext_pass parameter was deprecated. $notify added as a third parameter.from the docblock$plaintext_pass parameter was changed to $notify.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/pluggable.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.