Skip to content

Function

Register the registration form.

tml_register_registration_form( )

Source

function tml_register_registration_form() {
    // phpcs:disable WordPress.WP.I18n.MissingArgDomain -- these field labels intentionally reuse WP core's translated wp-login.php strings verbatim, not TML-specific strings.

    tml_register_form(
        'register',
        array(
            'action'     => tml_get_action_url( 'register' ),
            'attributes' => array_filter(
                array(
                    'novalidate' => 'novalidate',
                    'data-ajax'  => tml_use_ajax() ? 1 : 0,
                )
            ),
        )
    );

    if ( tml_is_default_registration_type() ) {
        tml_add_form_field(
            'register',
            'user_login',
            array(
                'type'       => 'text',
                'label'      => __( 'Username' ),
                'value'      => tml_get_request_value( 'user_login', 'post' ),
                'id'         => 'user_login',
                'attributes' => array(
                    'autocapitalize' => 'off',
                ),
                'priority'   => 10,
            )
        );
    } else {
        tml_add_form_field(
            'register',
            'user_login',
            array(
                'type'     => 'hidden',
                'label'    => '',
                'value'    => 'user' . md5( microtime() ),
                'id'       => 'user_login',
                'priority' => 10,
            )
        );
    }

    tml_add_form_field(
        'register',
        'user_email',
        array(
            'type'     => 'email',
            'label'    => __( 'Email' ),
            'value'    => tml_get_request_value( 'user_email', 'post' ),
            'id'       => 'user_email',
            'priority' => 15,
        )
    );

    if ( tml_allow_user_passwords() ) {
        tml_add_form_field(
            'register',
            'user_pass1',
            array(
                'type'       => 'password',
                'label'      => __( 'Password' ),
                'id'         => 'pass1',
                'attributes' => array(
                    'autocomplete' => 'off',
                ),
                'priority'   => 20,
            )
        );

        tml_add_form_field(
            'register',
            'user_pass2',
            array(
                'type'       => 'password',
                'label'      => __( 'Confirm Password', 'theme-my-login' ),
                'id'         => 'pass2',
                'attributes' => array(
                    'autocomplete' => 'off',
                ),
                'priority'   => 20,
            )
        );

        tml_add_form_field(
            'register',
            'indicator',
            array(
                'type'     => 'custom',
                'content'  => '<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite">' . __( 'Strength indicator' ) . '</div>',
                'priority' => 20,
            )
        );

        tml_add_form_field(
            'register',
            'indicator_hint',
            array(
                'type'     => 'custom',
                'content'  => '<p class="description indicator-hint">' . wp_get_password_hint() . '</p>',
                'priority' => 20,
            )
        );
    }

    tml_add_form_field(
        'register',
        'register_form',
        array(
            'type'     => 'action',
            'priority' => 25,
        )
    );

    if ( ! tml_allow_user_passwords() ) {
        tml_add_form_field(
            'register',
            'reg_passmail',
            array(
                'type'     => 'custom',
                'content'  => '<p id="reg_passmail">' . __( 'Registration confirmation will be emailed to you.' ) . '</p>',
                'priority' => 30,
            )
        );
    }

    tml_add_form_field(
        'register',
        'submit',
        array(
            'type'     => 'submit',
            'value'    => __( 'Register' ),
            'priority' => 35,
        )
    );

    tml_add_form_field(
        'register',
        'redirect_to',
        array(
            'type'     => 'hidden',
            'value'    => apply_filters( 'registration_redirect', tml_get_request_value( 'redirect_to' ) ),
            'priority' => 35,
        )
    );
    // phpcs:enable WordPress.WP.I18n.MissingArgDomain
}

Uses

Used by

Changelog

VersionDescription
7.0 Introduced.