Title: signup_user
Published: April 25, 2014
Last modified: February 24, 2026

---

# signup_user( string $user_name, string $user_email, WP_Error|string $errors )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#wp--skip-link--target)

Shows a form for a visitor to sign up for a new user account.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#parameters)󠁿

 `$user_name`stringrequired

The username.

`$user_email`stringrequired

The user’s email.

`$errors`[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
|stringrequired

A [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) object
containing existing errors. Defaults to empty string.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#source)󠁿

    ```php
    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
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-signup.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-signup.php#L591)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-signup.php#L591-L663)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#hooks)󠁿

 [do_action( ‘signup_hidden_fields’, string $context )](https://developer.wordpress.org/reference/hooks/signup_hidden_fields/)

Fires when hidden sign-up form fields output when creating another site or user.

 [apply_filters( ‘signup_user_init’, array $signup_user_defaults )](https://developer.wordpress.org/reference/hooks/signup_user_init/)

Filters the default user variables used on the user sign-up form.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#related)󠁿

| Uses | Description | 
| [get_network()](https://developer.wordpress.org/reference/functions/get_network/)`wp-includes/ms-network.php` |

Retrieves network data given a network ID or network object.

  | 
| [show_user_form()](https://developer.wordpress.org/reference/functions/show_user_form/)`wp-signup.php` |

Displays the fields for the new user account registration form.

  | 
| [esc_attr_e()](https://developer.wordpress.org/reference/functions/esc_attr_e/)`wp-includes/l10n.php` |

Displays translated text that has been escaped for safe use in an attribute.

  | 
| [checked()](https://developer.wordpress.org/reference/functions/checked/)`wp-includes/general-template.php` |

Outputs the HTML checked attribute.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_e()](https://developer.wordpress.org/reference/functions/_e/)`wp-includes/l10n.php` |

Displays translated text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 7 more](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#)

| Used by | Description | 
| [validate_user_signup()](https://developer.wordpress.org/reference/functions/validate_user_signup/)`wp-signup.php` |

Validates the new user sign-up.

  | 
| [validate_blog_signup()](https://developer.wordpress.org/reference/functions/validate_blog_signup/)`wp-signup.php` |

Validates new site signup.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/signup_user/?output_format=md#changelog)󠁿

| Version | Description | 
| [MU (3.0.0)](https://developer.wordpress.org/reference/since/mu.3.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fsignup_user%2F)
before being able to contribute a note or feedback.