signup_user( string $user_name = '', string $user_email = '', WP_Error|string $errors = '' )
- Since
- MU (3.0.0)
- Source
wp-signup.php:594
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_namestringoptional- The username.Default:
'' $user_emailstringoptional- The user's email.Default:
'' $errorsWP_Error|stringoptional- A WP_Error object containing existing errors. Defaults to empty string.Default:
''
Performance profile
How much work a call to 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
- Trivial
- Scaling
- Constant
- Instructions
- 61–94
- Plugin surface
- 2 hooks
- Called by
- 2
Touches nothing outside its own arguments.
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 99.
Third-party callbacks on 'signup_user_init', 'signup_hidden_fields' run inside this call, and their cost is not bounded by anything here.
2 places 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
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost signup_user() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($value) | 61–66 | is_wp_error(), apply_filters(), __(), get_network(), printf(), do_action(), show_user_form(), esc_attr_e() |
isset($value) | 68–73 | is_wp_error(), esc_html(), apply_filters(), __(), get_network(), printf(), do_action(), show_user_form(), esc_attr_e() |
!isset($value) && $active_signup !== "blog" && $active_signup !== "user" | 84–87 | is_wp_error(), apply_filters(), __(), get_network(), printf(), do_action(), show_user_form(), _e(), checked(), _e(), checked(), _e(), esc_attr_e() |
isset($value) && $active_signup !== "blog" && $active_signup !== "user" | 91–94 | is_wp_error(), esc_html(), apply_filters(), __(), get_network(), printf(), do_action(), show_user_form(), _e(), checked(), _e(), checked(), _e(), esc_attr_e() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 98 | 61–93 | 4 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 99 | 61–94 | 4 | |
| 8.4 | 99 | 61–94 | 4 | |
| 8.3 | 99 | 61–94 | 4 | |
| 8.2 | 99 | 61–94 | 4 | |
| 8.1 | 99 | 61–94 | 4 | |
| 7.4 | 99 | 61–94 | 4 |
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 signup_user() runs, in this order:
- apply_filters( signup_user_init )filterline 622 (+28 into the body)
Filters the default user variables used on the user sign-up form.
- do_action( signup_hidden_fields )actionline 639 (+45 into the body)
Fires when hidden sign-up form fields output when creating another site or user.
Uses · 11
- is_wp_error()Checks whether the given variable is a WordPress Error.
- esc_html()Escaping for HTML blocks.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- __()Retrieves the translation of $text.
- get_network()Retrieves network data given a network ID or network object.
- do_action()Calls the callback functions that have been added to an action hook.
- show_user_form()Displays the fields for the new user account registration form.
- _e()Displays translated text.
- checked()Outputs the HTML checked attribute.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
- WP_Error::__construct()Initializes the error.
Used by · 2
- validate_blog_signup()Validates new site signup.
- validate_user_signup()Validates the new user sign-up.
Source code
function signup_user( $user_name = '', $user_email = '', $errors = '' ) { global $active_signup; if ( ! is_wp_error( $errors ) ) { $errors = new WP_Error(); } $signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog'; $signup_user_defaults = array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors, ); /** * Filters the default user variables used on the user sign-up form. * * @since 3.0.0 * * @param array $signup_user_defaults { * An array of default user variables. * * @type string $user_name The user username. * @type string $user_email The user email address. * @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. * } */ $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); $user_name = $filtered_results['user_name']; $user_email = $filtered_results['user_email']; $errors = $filtered_results['errors']; ?> <h2> <?php /* translators: %s: Name of the network. */ printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); ?> </h2> <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> <input type="hidden" name="stage" value="validate-user-signup" /> <?php /** This action is documented in wp-signup.php */ do_action( 'signup_hidden_fields', 'validate-user' ); ?> <?php show_user_form( $user_name, $user_email, $errors ); ?> <?php if ( 'blog' === $active_signup ) : ?> <input id="signupblog" type="hidden" name="signup_for" value="blog" /> <?php elseif ( 'user' === $active_signup ) : ?> <input id="signupblog" type="hidden" name="signup_for" value="user" /> <?php else : ?> <fieldset class="signup-options"> <legend><?php _e( 'Create a site or only a username:' ); ?></legend> <p class="wp-signup-radio-buttons"> <span class="wp-signup-radio-button"> <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> <label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ); ?></label> </span> <span class="wp-signup-radio-button"> <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ); ?></label> </span> </p> </fieldset> <?php endif; ?> <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next' ); ?>" /></p> </form> <?php}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.0.4 tag, from
src/wp-signup.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.