wppaste
WordPress

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
Emails login credentials to a newly-registered user.

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

Sends mail via wp_mail().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
8–204

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 213.

Plugin surface
4 hooks

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.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_user_by()called directly
  • mailsends mailwp_mail()called directly
  • cacheobject cachewp_cache_get()one call below wp_new_user_notification()
  • serializeserialisationmaybe_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.

WhenInstructionsCalls it makes
$deprecated === null && !$notify8none
$deprecated !== null && !$notify12_deprecated_argument()
$deprecated === null && $notify36–44get_userdata(), get_option(), wp_specialchars_decode(), apply_filters(), apply_filters()
$deprecated !== null && $notify40–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–52get_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–113get_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–115get_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 === true120–126get_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 === true121–127get_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 === true122–128get_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 === true123–129get_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 === true124–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 === true125–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 === true126–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 === true127–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–134get_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–135get_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–136get_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–137get_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–195get_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–196get_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–197get_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–197get_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–198get_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–198get_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–199get_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–200get_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:

  1. 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.

  2. 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.

  3. 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.

  4. 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

Show all 15

Used by · 1

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.0.4
Parameter $deprecated retyped from null to mixed.verified against source
4.6.0
The $notify parameter accepts 'user' for sending notification only to the user created.from the docblock
4.3.1
The $plaintext_pass parameter was deprecated. $notify added as a third parameter.from the docblock
4.3.0
The $plaintext_pass parameter was changed to $notify.from the docblock
2.0.0
Introduced.from the docblock

About 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.