wpmu_signup_user( string $user, string $user_email, array $meta = array() )
- Since
- MU (3.0.0)
- Source
wp-includes/ms-functions.php:868
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
- Scaling
- Constant
- Instructions
- 63
- Plugin surface
- 2 hooks
- Called by
- 1
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 63.
Third-party callbacks on 'signup_user_meta', 'after_signup_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
- hookthird-party callbacks
apply_filters()called directly - serializeserialisation
serialize()called directly - transienttransient
get_transient()one call below wpmu_signup_user() - optionoption read or write
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 63 | sanitize_user(), sanitize_email(), time(), wp_rand(), md5(), apply_filters(), current_time(), serialize(), domain(), do_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 63 | 63 | 0 | |
| 8.5 | 63 | 63 | 0 | |
| 8.4 | 63 | 63 | 0 | 7 fewer instructions than PHP 8.3 |
| 8.3 | 70 | 70 | 0 | |
| 8.2 | 70 | 70 | 0 | |
| 8.1 | 70 | 70 | 0 | |
| 7.4 | 70 | 70 | 0 |
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:
- apply_filters( signup_user_meta )filterline 888 (+20 into the body)
Filters the metadata for a user signup.
- do_action( after_signup_user )actionline 914 (+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
- validate_user_signup()Validates the new user sign-up.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.