Skip to content

Function

Register the user signup form.

tml_ms_register_user_signup_form( )

Source

function tml_ms_register_user_signup_form() {

    tml_register_form(
        'user_signup',
        array(
            'action'      => tml_get_action_url( 'signup' ),
            'attributes'  => array(
                'id'         => 'setupform',
                'novalidate' => 'novalidate',
            ),
            'render_args' => array(
                'show_links' => false,
            ),
        )
    );

    tml_add_form_field(
        'user_signup',
        'stage',
        array(
            'type'     => 'hidden',
            'value'    => 'validate-user-signup',
            'priority' => 5,
        )
    );

    tml_add_form_field(
        'user_signup',
        'signup_hidden_fields',
        array(
            'type'        => 'action',
            'render_args' => array( 'validate-user' ),
        )
    );

    if ( tml_is_default_registration_type() ) {
        tml_add_form_field(
            'user_signup',
            'user_name',
            array(
                'type'        => 'text',
                'label'       => __( 'Username:' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated "Username:" string (see wp-signup.php), not a TML-specific string.
                'description' => __( '(Must be at least 4 characters, lowercase letters and numbers only.)' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string (see wp-signup.php), not a TML-specific string.
                'value'       => '',
                'id'          => 'user_name',
                'attributes'  => array(
                    'autocapitalize' => 'none',
                    'autocorrect'    => 'off',
                    'maxlength'      => 60,
                ),
                'priority'    => 10,
            )
        );
    } else {
        tml_add_form_field(
            'user_signup',
            'user_name',
            array(
                'type'     => 'hidden',
                'label'    => '',
                'value'    => 'user' . md5( microtime() ),
                'id'       => 'user_name',
                'priority' => 10,
            )
        );
    }

    tml_add_form_field(
        'user_signup',
        'user_email',
        array(
            'type'        => 'email',
            'label'       => __( 'Email Address:' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated "Email Address:" string (see wp-signup.php), not a TML-specific string.
            'description' => __( 'Your registration email is sent to this address. (Double-check your email address before continuing.)' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string (see wp-signup.php), not a TML-specific string.
            'value'       => '',
            'id'          => 'user_email',
            'attributes'  => array(
                'maxlength' => 200,
            ),
            'priority'    => 15,
        )
    );

    tml_add_form_field(
        'user_signup',
        'signup_extra_fields',
        array(
            'type'        => 'action',
            'render_args' => array( tml_get_errors() ),
        )
    );

    $active_signup = tml_ms_signup_get_active_signup();

    if ( 'blog' === $active_signup ) {
        tml_add_form_field(
            'user_signup',
            'signup_for',
            array(
                'type'     => 'hidden',
                'value'    => 'blog',
                'id'       => 'signupblog',
                'priority' => 20,
            )
        );
    } elseif ( 'user' === $active_signup ) {
        tml_add_form_field(
            'user_signup',
            'signup_for',
            array(
                'type'     => 'hidden',
                'value'    => 'user',
                'id'       => 'signupuser',
                'priority' => 20,
            )
        );
    } else {
        tml_add_form_field(
            'user_signup',
            'signup_for',
            array(
                'type'     => 'radio-group',
                // phpcs:disable WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated wp-signup.php strings verbatim, not TML-specific strings.
                'options'  => array(
                    'blog' => __( 'Gimme a site!' ),
                    'user' => __( 'Just a username, please.' ),
                ),
                // phpcs:enable WordPress.WP.I18n.MissingArgDomain
                'value'    => isset( $_POST['signup_for'] ) ? $_POST['signup_for'] : 'blog', // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only: pre-fills the field's default selection, not processed/acted on.
                'priority' => 20,
            )
        );
    }

    tml_add_form_field(
        'user_signup',
        'submit',
        array(
            'type'     => 'submit',
            'name'     => 'submit',
            'value'    => __( 'Next' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated "Next" string (see wp-signup.php), not a TML-specific string.
            'priority' => 25,
        )
    );
}

Uses

Used by

Changelog

VersionDescription
7.0 Introduced.