WordPress.org

  • Showcase
  • Themes
  • Plugins
  • Mobile
  • Support
    • Documentation
    • Forums
  • Get Involved
  • About
  • Blog
  • Hosting
  • Get WordPress

Code Reference

Skip to content
    Filter by type:
    Search
    Browse: Home / Reference / Functions / signup_user()

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

    Setup the new user signup process

    Contents

    • Description
      • Parameters
      • Source
      • Changelog
    • Related
      • Uses
      • Used By
    • User Contributed Notes

    Description #Description


    Parameters #Parameters

    $user_name

    (string) (Optional) The username.

    Default value: ''

    $user_email

    (string) (Optional) The user's email.

    Default value: ''

    $errors

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

    Default value: ''


    Top ↑

    Source #Source

    File: wp-signup.php

    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    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 ); ?>
     
            <p>
            <?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 { ?>
                <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 full source code Collapse full source code View on Trac


    Top ↑

    Changelog #Changelog

    Changelog
    Version Description
    MU (3.0.0) Introduced.

    Top ↑

    Related #Related

    Top ↑

    Uses #Uses

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

    Retrieves network data given a network ID or network object.

    wp-signup.php: show_user_form()

    Display user 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/l10n.php: __()

    Retrieve the translation of $text.

    wp-includes/l10n.php: _e()

    Display translated text.

    wp-includes/l10n.php: esc_attr_e()

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

    wp-includes/formatting.php: esc_html()

    Escaping for HTML blocks.

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

    Outputs the html checked attribute.

    wp-includes/plugin.php: apply_filters()

    Call the functions added to a filter hook.

    wp-includes/plugin.php: do_action()

    Execute functions hooked on a specific action hook.

    wp-includes/load.php: is_wp_error()

    Check whether variable is a WordPress Error.

    wp-includes/class-wp-error.php: WP_Error::__construct()

    Initialize the error.

    Show 8 more uses Hide more uses

    Top ↑

    Used By #Used By

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

    Validate the new user signup

    wp-signup.php: validate_blog_signup()

    Validate new site signup


    Top ↑

    User Contributed Notes #User Contributed Notes

    You must log in before being able to contribute a note or feedback.

    • About
    • Blog
    • Hosting
    • Donate
    • Support
    • Developers
    • Get Involved
    • Showcase
    • Plugins
    • Themes
    • WordCamp
    • WordPress.TV
    • BuddyPress
    • bbPress
    • WordPress.com
    • Matt
    • Privacy
    • Public Code
    • @WordPress
    • WordPress

    Code is Poetry.

    Skip to toolbar
    • About WordPress
      • About WordPress
      • WordPress.org
      • Documentation
      • Support
      • Feedback
    • Log In
    • Register