Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#57089 new enhancement

Automatically log-in a user

Reported by: ratkosolaja's profile ratkosolaja Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords:
Focuses: Cc:

Description

?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

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

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( '/' ) ) ) );

Change History (1)

This ticket was mentioned in Slack in #core by ratkosolaja. View the logs.


2 years ago

Note: See TracTickets for help on using tickets.