[wp-trac] [WordPress Trac] #57089: Automatically log-in a user

WordPress Trac noreply at wordpress.org
Sat Nov 12 12:52:57 UTC 2022


#57089: Automatically log-in a user
-------------------------+-----------------------------
 Reporter:  ratkosolaja  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Users        |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 **?PROBLEM:**

 At the moment, when a user successfully resets their password they are
 presented with a screen prompting them to go to log in page and log in.

 **PROPOSED SOLTION:**
 Automatically log in the user after successful password reset and redirect
 them to:

 - Site home page - if they aren’t an admin.
 - Site Dashboard (wp-admin) if they are an admin.

 If we would like to give site owners an option, maybe we could have a
 toggle (checkbox) under Settings -> General that would control this -
 meaning, toggle between current option and proposed one.

 Basic gist would be to remove the following lines of code inside wp-
 login.php file:
 {{{#!php
 <?php

 login_header( __( 'Password Reset' ), '<p class="message reset-pass">' .
 __( 'Your password has been reset.' ) . ' <a href="' . esc_url(
 wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
 login_footer();

 }}}

 and replace it with something like:
 {{{#!php
 <?php

 wp_clear_auth_cookie();
 wp_set_current_user( $user->ID );
 wp_set_auth_cookie( $user->ID );

 wp_safe_redirect( apply_filters( 'password_reset_redirect', esc_url(
 home_url( '/' ) ) ) );

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57089>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list