Function
Register the password reset form.
tml_register_password_reset_form( )
Source
function tml_register_password_reset_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(
'resetpass',
array(
'action' => tml_get_action_url( 'resetpass' ),
'attributes' => array(
'autocomplete' => 'off',
),
'render_args' => array(
'show_links' => false,
),
)
);
tml_add_form_field(
'resetpass',
'pass1',
array(
'type' => 'password',
'label' => __( 'New password' ),
'id' => 'pass1',
'attributes' => array(
'autocomplete' => 'off',
'aria-describedby' => 'pass-strength-result',
),
'priority' => 10,
)
);
tml_add_form_field(
'resetpass',
'pass2',
array(
'type' => 'password',
'label' => __( 'Confirm new password' ),
'id' => 'pass2',
'attributes' => array(
'autocomplete' => 'off',
'aria-describedby' => 'pass-strength-result',
),
'priority' => 10,
)
);
tml_add_form_field(
'resetpass',
'indicator',
array(
'type' => 'custom',
'content' => '<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite">' . __( 'Strength indicator' ) . '</div>',
'priority' => 10,
)
);
tml_add_form_field(
'resetpass',
'indicator_hint',
array(
'type' => 'custom',
'content' => '<p class="description indicator-hint">' . wp_get_password_hint() . '</p>',
'priority' => 10,
)
);
tml_add_form_field(
'resetpass',
'resetpass_form',
array(
'type' => 'action',
'priority' => 15,
'render_args' => array( wp_get_current_user() ),
)
);
tml_add_form_field(
'resetpass',
'submit',
array(
'type' => 'submit',
'value' => __( 'Save Password' ),
'priority' => 20,
)
);
// phpcs:enable WordPress.WP.I18n.MissingArgDomain
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
tml_add_form_field(
'resetpass',
'rp_key',
array(
'type' => 'hidden',
'value' => $rp_key,
'priority' => 20,
)
);
}
}
Uses
Used by
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |