Skip to content

Function

Register the login form.

tml_register_login_form( )

Source

function tml_register_login_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(
        'login',
        array(
            'action'      => tml_get_action_url( 'login' ),
            'attributes'  => array_filter(
                array(
                    'data-ajax' => tml_use_ajax() ? 1 : 0,
                )
            ),
            // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only: just toggles whether the login form itself is shown, not processed/acted on.
            'render_args' => isset( $_GET['checkemail'] ) ? array(
                'show_form'  => false,
                'show_links' => false,
            ) : array(),
        )
    );

    tml_add_form_field(
        'login',
        'log',
        array(
            'type'       => 'text',
            'label'      => tml_get_username_label( 'login' ),
            'value'      => tml_get_request_value( 'log', 'post' ),
            'id'         => 'user_login',
            'attributes' => array(
                'autocapitalize' => 'off',
            ),
            'priority'   => 10,
        )
    );

    tml_add_form_field(
        'login',
        'pwd',
        array(
            'type'     => 'password',
            'label'    => __( 'Password' ),
            'value'    => '',
            'id'       => 'user_pass',
            'priority' => 15,
        )
    );

    tml_add_form_field(
        'login',
        'login_form',
        array(
            'type'     => 'action',
            'priority' => 20,
        )
    );

    tml_add_form_field(
        'login',
        'rememberme',
        array(
            'type'     => 'checkbox',
            'label'    => __( 'Remember Me' ),
            'value'    => 'forever',
            'id'       => 'rememberme',
            'priority' => 25,
        )
    );

    tml_add_form_field(
        'login',
        'submit',
        array(
            'type'     => 'submit',
            'value'    => __( 'Log In' ),
            'priority' => 30,
        )
    );

    $redirect_to = tml_get_request_value( 'redirect_to' );

    tml_add_form_field(
        'login',
        'redirect_to',
        array(
            'type'     => 'hidden',
            'value'    => ! empty( $redirect_to ) ? $redirect_to : admin_url(),
            'priority' => 30,
        )
    );
    // phpcs:enable WordPress.WP.I18n.MissingArgDomain
}

Uses

Used by

Changelog

VersionDescription
7.0 Introduced.