wppaste
WordPress

wpmu_signup_user_notification( string $user_login, string $user_email, string $key, array $meta = array() ): bool

Since
MU (3.0.0)
Source
wp-includes/ms-functions.php:1060
Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked.

Description

This is the notification function used when no new site has been requested.

Filter 'wpmu_signup_user_notification' to bypass this function or replace it with your own notification behavior.

Filter 'wpmu_signup_user_notification_email' and 'wpmu_signup_user_notification_subject' to change the content and subject line of the email sent to newly registered users.

Compatibility

WordPress
since MU (3.0.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_loginstring
The user's login name.
$user_emailstring
The user's email address.
$keystring
The activation key created in wpmu_signup_user()
$metaarrayoptional
Signup meta data. Default empty array.Default: array()

Return value

bool

Performance profile

How much work a call to wpmu_signup_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
13–115

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

Plugin surface
3 hooks

Third-party callbacks on 'wpmu_signup_user_notification', 'wpmu_signup_user_notification_email', 'wpmu_signup_user_notification_subject' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_user_by()called directly
  • optionnetwork optionget_site_option()called directly
  • mailsends mailwp_mail()called directly
  • cacheobject cachewp_cache_get()one call below wpmu_signup_user_notification()
  • serializeserialisationmaybe_unserialize()one call below wpmu_signup_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 · 17 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wpmu_signup_user_notification() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!apply_filters()13apply_filters()
apply_filters() && $admin_email !== ""92apply_filters(), get_user_by(), get_site_option(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email !== ""94apply_filters(), get_user_by(), get_site_option(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email !== ""98apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email !== ""99apply_filters(), get_user_by(), get_site_option(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email === ""100apply_filters(), get_user_by(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email !== ""100apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email !== ""101apply_filters(), get_user_by(), get_site_option(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email === ""102apply_filters(), get_user_by(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email !== ""105apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email === ""106apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email === ""107apply_filters(), get_user_by(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
5 further outcomes, up to 115 instructions
apply_filters() && $admin_email !== ""107apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email === ""108apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email === ""109apply_filters(), get_user_by(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()
apply_filters() && $admin_email === ""113apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail()
apply_filters() && $admin_email === ""115apply_filters(), get_user_by(), switch_to_user_locale(), get_site_option(), network_home_url(), wp_parse_url(), get_site_option(), get_site_option(), esc_html(), get_option(), __(), apply_filters(), site_url(), sprintf(), _x(), apply_filters(), sprintf(), wp_specialchars_decode(), wp_mail(), restore_previous_locale()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev11613–11451 fewer instruction than PHP 8.5
8.511713–1155
8.411713–1155
8.311713–1155
8.211713–1155
8.111713–1155
7.411713–1155

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

3 hooks fire while wpmu_signup_user_notification() runs, in this order:

  1. apply_filters( wpmu_signup_user_notification )filterline 1071 (+11 into the body)

    Filters whether to bypass the email notification for new user sign-up.

  2. apply_filters( wpmu_signup_user_notification_email )filterline 1101 (+41 into the body)

    Filters the content of the notification email for new user sign-up.

  3. apply_filters( wpmu_signup_user_notification_subject )filterline 1125 (+65 into the body)

    Filters the subject of the notification email of new user signup.

Uses · 14

  • 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.
  • get_site_option()Retrieve an option value for the current network based on name of option.
  • wp_parse_url()A wrapper for PHP's parse_url() function that handles consistency in the return values across PHP versions.
  • network_home_url()Retrieves the home URL for the current network.
  • esc_html()Escaping for HTML blocks.
  • get_option()Retrieves an option value based on an option name.
  • __()Retrieves the translation of $text.
  • site_url()Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
  • _x()Retrieves translated string with gettext context.
  • wp_mail()Sends an email, similar to PHP's mail function.
Show all 14

Source code

function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array() ) {	/**	 * Filters whether to bypass the email notification for new user sign-up.	 *	 * @since MU (3.0.0)	 *	 * @param string $user_login User login name.	 * @param string $user_email User email address.	 * @param string $key        Activation key created in wpmu_signup_user().	 * @param array  $meta       Signup meta data. Default empty array.	 */	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) {		return false;	} 	$user            = get_user_by( 'login', $user_login );	$switched_locale = $user && switch_to_user_locale( $user->ID ); 	// Send email with activation link.	$admin_email = get_site_option( 'admin_email' ); 	if ( '' === $admin_email ) {		$admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );	} 	$from_name       = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress';	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";	$message         = sprintf(		/**		 * Filters the content of the notification email for new user sign-up.		 *		 * Content should be formatted for transmission via wp_mail().		 *		 * @since MU (3.0.0)		 *		 * @param string $content    Content of the notification email.		 * @param string $user_login User login name.		 * @param string $user_email User email address.		 * @param string $key        Activation key created in wpmu_signup_user().		 * @param array  $meta       Signup meta data. Default empty array.		 */		apply_filters(			'wpmu_signup_user_notification_email',			/* translators: New user notification email. %s: Activation URL. */			__( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),			$user_login,			$user_email,			$key,			$meta		),		site_url( "wp-activate.php?key=$key" )	); 	$subject = sprintf(		/**		 * Filters the subject of the notification email of new user signup.		 *		 * @since MU (3.0.0)		 *		 * @param string $subject    Subject of the notification email.		 * @param string $user_login User login name.		 * @param string $user_email User email address.		 * @param string $key        Activation key created in wpmu_signup_user().		 * @param array  $meta       Signup meta data. Default empty array.		 */		apply_filters(			'wpmu_signup_user_notification_subject',			/* translators: New user notification email subject. 1: Network title, 2: New user login. */			_x( '[%1$s] Activate %2$s', 'New user notification email subject' ),			$user_login,			$user_email,			$key,			$meta		),		$from_name,		$user_login	); 	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );

Changelog

Introduced in MU (3.0.0). Unchanged from 6.7.7 through 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.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/ms-functions.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.