wppaste
WordPress

wpmu_signup_user( string $user, string $user_email, array $meta = array() )

Since
MU (3.0.0)
Source
wp-includes/ms-functions.php:851
Records user signup information for future activation.

Description

This function is used when user registration is open but new site registration is not.

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

$userstring
The user's requested login name.
$user_emailstring
The user's email address.
$metaarrayoptional
Signup meta data. Default empty array.Default: array()

Performance profile

How much work a call to wpmu_signup_user() 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
Moderate

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Constant

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

Instructions
63

Executed per call on PHP 8.5. The body compiles to 63.

Plugin surface
2 hooks

Third-party callbacks on 'signup_user_meta', 'after_signup_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

  • hookthird-party callbacksapply_filters()called directly
  • serializeserialisationserialize()called directly
  • transienttransientget_transient()one call below wpmu_signup_user()
  • optionoption read or writeget_option()one call below wpmu_signup_user()

Further down the call graph this can also reach cache and query. 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 wpmu_signup_user() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always63sanitize_user(), sanitize_email(), time(), wp_rand(), md5(), apply_filters(), current_time(), serialize(), domain(), do_action()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev63630
8.563630
8.4636307 fewer instructions than PHP 8.3
8.370700
8.270700
8.170700
7.470700

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

2 hooks fire while wpmu_signup_user() runs, in this order:

  1. apply_filters( signup_user_meta )filterline 871 (+20 into the body)

    Filters the metadata for a user signup.

  2. do_action( after_signup_user )actionline 897 (+46 into the body)

    Fires after a user's signup information has been written to the database.

Uses · 6

  • sanitize_user()Sanitizes a username, stripping out unsafe characters.
  • sanitize_email()Strips out all characters that are not allowable in an email.
  • wp_rand()Generates a random non-negative number.
  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • current_time()Retrieves the current time based on specified type.
  • do_action()Calls the callback functions that have been added to an action hook.

Used by · 1

Source code

function wpmu_signup_user( $user, $user_email, $meta = array() ) {	global $wpdb; 	// Format data.	$user       = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );	$user_email = sanitize_email( $user_email );	$key        = substr( md5( time() . wp_rand() . $user_email ), 0, 16 ); 	/**	 * Filters the metadata for a user signup.	 *	 * The metadata will be serialized prior to storing it in the database.	 *	 * @since 4.8.0	 *	 * @param array  $meta       Signup meta data. Default empty array.	 * @param string $user       The user's requested login name.	 * @param string $user_email The user's email address.	 * @param string $key        The user's activation key.	 */	$meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key ); 	$wpdb->insert(		$wpdb->signups,		array(			'domain'         => '',			'path'           => '',			'title'          => '',			'user_login'     => $user,			'user_email'     => $user_email,			'registered'     => current_time( 'mysql', true ),			'activation_key' => $key,			'meta'           => serialize( $meta ),		)	); 	/**	 * Fires after a user's signup information has been written to the database.	 *	 * @since 4.4.0	 *	 * @param string $user       The user's requested login name.	 * @param string $user_email The user's email address.	 * @param string $key        The user's activation key.	 * @param array  $meta       Signup meta data. Default empty array.	 */	do_action( 'after_signup_user', $user, $user_email, $key, $meta );}

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.