ClassicPress logo
Skip to content
Filter by type:

Browse:

  • Home
  • Functions
  • signup_user()

signup_user( string $user_name = '', string $user_email = '', WP_Error|string $errors = '' )

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


Parameters

$user_name

(Optional) The username.

Default value: ''

$user_email

(Optional) The user's email.

Default value: ''

$errors

(Optional) A WP_Error object containing existing errors. Defaults to empty string.

Default value: ''


Source

File: wp-signup.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 WP-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); ?>

		<p>
		<?php if ( $active_signup == 'blog' ) { ?>
			<input id="signupblog" type="hidden" name="signup_for" value="blog" />
		<?php } elseif ( $active_signup == 'user' ) { ?>
			<input id="signupblog" type="hidden" name="signup_for" value="user" />
		<?php } else { ?>
			<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>
			<br />
			<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>
		<?php } ?>
		</p>

		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
	</form>
	<?php
}

Expand Source Code View on GitHub


Related

Uses

Uses
Uses Description
wp-signup.php: show_user_form()

Displays the fields for the new user account registration form.

wp-signup.php: signup_user_init

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

wp-signup.php: signup_hidden_fields

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

wp-includes/general-template.php: checked()

Outputs the HTML checked attribute.

wp-includes/ms-network.php: get_network()

Retrieves network data given a network ID or network object.

wp-includes/plugin.php: do_action()

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

wp-includes/plugin.php: apply_filters()

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

Show 2 more uses Hide more uses

Used By

Used By
Used By Description
wp-signup.php: validate_user_signup()

Validates the new user sign-up.

wp-signup.php: validate_blog_signup()

Validates new site signup.


Changelog

Changelog
Version Description
MU (3.0.0) Introduced. MU (3.0.0)
ClassicPress Documentation • Made with ClassicPress
Privacy Policy