* Handles the user registration and site creation process for multisite installations.
/** Sets up the WordPress Environment. */
require __DIR__ . '/wp-load.php';
add_filter( 'wp_robots', 'wp_robots_no_robots' );
require __DIR__ . '/wp-blog-header.php';
if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ), true ) ) {
wp_redirect( network_home_url() );
* Prints signup_header via wp_head.
function do_signup_header() {
* Fires within the head section of the site sign-up screen.
do_action( 'signup_header' );
add_action( 'wp_head', 'do_signup_header' );
if ( ! is_multisite() ) {
wp_redirect( wp_registration_url() );
if ( ! is_main_site() ) {
wp_redirect( network_site_url( 'wp-signup.php' ) );
$wp_query->is_404 = false;
* Fires before the Site Sign-up page is loaded.
do_action( 'before_signup_header' );
* Prints styles for front-end Multisite Sign-up pages.
function wpmu_signup_stylesheet() {
.mu_register { width: 90%; margin: 0 auto; }
.mu_register form { margin-top: 2em; }
.mu_register legend { margin: 0; padding: 0; border: none; }
.mu_register .error { padding: 10px; color: #333; background: #ffebe8; border: 1px solid #c00; }
.mu_register input[type="submit"],
.mu_register #blog_title,
.mu_register #user_email,
.mu_register #user_name { width: 100%; font-size: 24px; margin: 5px 0; box-sizing: border-box; }
.mu_register #site-language { display: block; }
.mu_register .prefix_address,
.mu_register .suffix_address { font-size: 18px; display: inline-block; direction: ltr; }
.mu_register .label-heading { font-weight: 600; font-size: 15px; display: block; margin: 10px 0; }
.mu_register input + p { margin-top: 0; }
.mu_register label.checkbox { display: inline; }
.mu_register .mu_alert { font-weight: 600; padding: 10px; color: #333; background: #ffffe0; border: 1px solid #e6db55; }
.mu_register .mu_alert a { color: inherit; text-decoration: underline; }
.mu_register .signup-options .wp-signup-radio-button { display: block; }
.mu_register .privacy-intro .wp-signup-radio-button { margin-right: 0.5em; }
.rtl .mu_register .wp-signup-blogname { direction: ltr; text-align: right; }
add_action( 'wp_head', 'wpmu_signup_stylesheet' );
get_header( 'wp-signup' );
* Fires before the site Sign-up form.
do_action( 'before_signup_form' );
<div id="signup-content" class="widecolumn">
<div class="mu_register wp-signup-container" role="main">
* Generates and displays the Sign-up and Create Site forms.
* @param string $blogname The new site name.
* @param string $blog_title The new site title.
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.
function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
$current_network = get_network();
if ( ! is_subdomain_install() ) {
echo '<label for="blogname">' . __( 'Site Name (subdirectory only):' ) . '</label>';
echo '<label for="blogname">' . __( 'Site Domain (subdomain only):' ) . '</label>';
$errmsg_blogname = $errors->get_error_message( 'blogname' );
$errmsg_blogname_aria = '';
if ( $errmsg_blogname ) {
$errmsg_blogname_aria = 'wp-signup-blogname-error ';
echo '<p class="error" id="wp-signup-blogname-error">' . $errmsg_blogname . '</p>';
if ( ! is_subdomain_install() ) {
echo '<div class="wp-signup-blogname"><span class="prefix_address" id="prefix-address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" autocomplete="off" required="required" aria-describedby="' . $errmsg_blogname_aria . 'prefix-address" /></div>';
$site_domain = preg_replace( '|^www\.|', '', $current_network->domain );
echo '<div class="wp-signup-blogname"><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" autocomplete="off" required="required" aria-describedby="' . $errmsg_blogname_aria . 'suffix-address" /><span class="suffix_address" id="suffix-address">.' . esc_html( $site_domain ) . '</span></div>';
if ( ! is_user_logged_in() ) {
if ( ! is_subdomain_install() ) {
$site = $current_network->domain . $current_network->path . __( 'sitename' );
$site = __( 'domain' ) . '.' . $site_domain . $current_network->path;
'<p>(<strong>%s</strong>) %s</p>',
/* translators: %s: Site address. */
sprintf( __( 'Your address will be %s.' ), $site ),
__( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' )
<label for="blog_title"><?php _e( 'Site Title:' ); ?></label>
$errmsg_blog_title = $errors->get_error_message( 'blog_title' );
$errmsg_blog_title_aria = '';
if ( $errmsg_blog_title ) {
$errmsg_blog_title_aria = ' aria-describedby="wp-signup-blog-title-error"';
echo '<p class="error" id="wp-signup-blog-title-error">' . $errmsg_blog_title . '</p>';
echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" required="required" autocomplete="off"' . $errmsg_blog_title_aria . ' />';
$languages = signup_get_available_languages();
if ( ! empty( $languages ) ) :
<label for="site-language"><?php _e( 'Site Language:' ); ?></label>
$lang = get_site_option( 'WPLANG' );
if ( isset( $_POST['WPLANG'] ) ) {
$lang = $_POST['WPLANG'];
// Use US English if the default isn't available.
if ( ! in_array( $lang, $languages, true ) ) {
'languages' => $languages,
'show_available_translations' => false,
$blog_public_on_checked = '';
$blog_public_off_checked = '';
if ( isset( $_POST['blog_public'] ) && '0' === $_POST['blog_public'] ) {
$blog_public_off_checked = 'checked="checked"';
$blog_public_on_checked = 'checked="checked"';
<fieldset class="privacy-intro">
<span class="label-heading"><?php _e( 'Privacy:' ); ?></span>
<?php _e( 'Allow search engines to index this site.' ); ?>
<p class="wp-signup-radio-buttons">
<span class="wp-signup-radio-button">
<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> />
<label class="checkbox" for="blog_public_on"><?php _e( 'Yes' ); ?></label>
<span class="wp-signup-radio-button">
<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> />
<label class="checkbox" for="blog_public_off"><?php _e( 'No' ); ?></label>
* Fires after the site sign-up form.
* @param WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors.
do_action( 'signup_blogform', $errors );
* Validates the new site sign-up.
* @return array Contains the new site data and error messages.
* See wpmu_validate_blog_signup() for details.
function validate_blog_form() {
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user );
* Displays the fields for the new user account registration form.
* @param string $user_name The entered username.
* @param string $user_email The entered email address.
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.
function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
echo '<label for="user_name">' . __( 'Username:' ) . '</label>';
$errmsg_username = $errors->get_error_message( 'user_name' );
$errmsg_username_aria = '';
if ( $errmsg_username ) {
$errmsg_username_aria = 'wp-signup-username-error ';
echo '<p class="error" id="wp-signup-username-error">' . $errmsg_username . '</p>';
<input name="user_name" type="text" id="user_name" value="<?php echo esc_attr( $user_name ); ?>" autocapitalize="none" autocorrect="off" maxlength="60" autocomplete="username" required="required" aria-describedby="<?php echo $errmsg_username_aria; ?>wp-signup-username-description" />
<p id="wp-signup-username-description"><?php _e( '(Must be at least 4 characters, lowercase letters and numbers only.)' ); ?></p>
echo '<label for="user_email">' . __( 'Email Address:' ) . '</label>';
$errmsg_email = $errors->get_error_message( 'user_email' );
$errmsg_email_aria = 'wp-signup-email-error ';
echo '<p class="error" id="wp-signup-email-error">' . $errmsg_email . '</p>';
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" autocomplete="email" required="required" aria-describedby="<?php echo $errmsg_email_aria; ?>wp-signup-email-description" />
<p id="wp-signup-email-description"><?php _e( 'Your registration email is sent to this address. (Double-check your email address before continuing.)' ); ?></p>
$errmsg_generic = $errors->get_error_message( 'generic' );
echo '<p class="error" id="wp-signup-generic-error">' . $errmsg_generic . '</p>';
* Fires at the end of the new user account registration form.
* @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors.
do_action( 'signup_extra_fields', $errors );
* Validates user sign-up name and email.
* @return array Contains username, email, and error messages.
* See wpmu_validate_user_signup() for details.
function validate_user_form() {
return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
* Shows a form for returning users to sign up for another site.
* @param string $blogname The new site name
* @param string $blog_title The new site title.
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
$current_user = wp_get_current_user();
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
$signup_defaults = array(
'blog_title' => $blog_title,
* Filters the default site sign-up variables.
* @param array $signup_defaults {
* An array of default site sign-up variables.
* @type string $blogname The site blogname.
* @type string $blog_title The site title.
* @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors.
$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
$blogname = $filtered_results['blogname'];
$blog_title = $filtered_results['blog_title'];
$errors = $filtered_results['errors'];
/* translators: %s: Network title. */
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
if ( $errors->has_errors() ) {
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
/* translators: %s: Current user's display name. */
__( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ),
$current_user->display_name
$blogs = get_blogs_of_user( $current_user->ID );
if ( ! empty( $blogs ) ) {
<p><?php _e( 'Sites you are already a member of:' ); ?></p>
foreach ( $blogs as $blog ) {
$home_url = get_home_url( $blog->userblog_id );
echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
<p><?php _e( 'If you are not going to use a great site domain, leave it for a new user. Now have at it!' ); ?></p>
<form id="setupform" method="post" action="wp-signup.php">
<input type="hidden" name="stage" value="gimmeanotherblog" />
* Fires when hidden sign-up form fields output when creating another site or user.
* @param string $context A string describing the steps of the sign-up process. The value can be
* 'create-another-site', 'validate-user', or 'validate-site'.
do_action( 'signup_hidden_fields', 'create-another-site' );
<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ); ?>" /></p>
* Validates a new site sign-up for an existing user.
* @global string $blogname The new site's subdomain or directory name.
* @global string $blog_title The new site's title.
* @global WP_Error $errors Existing errors in the global scope.
* @global string $domain The new site's domain.
* @global string $path The new site's path.
* @return null|bool True if site signup was validated, false on error.
* The function halts all execution if the user is not logged in.
function validate_another_blog_signup() {
global $blogname, $blog_title, $errors, $domain, $path;
$current_user = wp_get_current_user();
if ( ! is_user_logged_in() ) {
$result = validate_blog_form();
// Extracted values set/overwrite globals.
$domain = $result['domain'];
$blogname = $result['blogname'];
$blog_title = $result['blog_title'];
$errors = $result['errors'];
if ( $errors->has_errors() ) {
signup_another_blog( $blogname, $blog_title, $errors );
$public = (int) $_POST['blog_public'];
$blog_meta_defaults = array(
// Handle the language setting for the new site.
if ( ! empty( $_POST['WPLANG'] ) ) {
$languages = signup_get_available_languages();
if ( in_array( $_POST['WPLANG'], $languages, true ) ) {
$language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) );
$blog_meta_defaults['WPLANG'] = $language;
* Filters the new site meta variables.
* Use the {@see 'add_signup_meta'} filter instead.
* @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead.
* @param array $blog_meta_defaults An array of default blog meta variables.
$meta_defaults = apply_filters_deprecated( 'signup_create_blog_meta', array( $blog_meta_defaults ), '3.0.0', 'add_signup_meta' );
* Filters the new default site meta variables.
* An array of default site meta variables.
* @type int $lang_id The language ID.