Open inf3cti0n95 opened 1 year ago
+1
We are considering adding this feature in next release - however, not final yet.
Thanks for pointing this out.
+1 pretty useless for my users without this...
perhaps could borrow some tactics from this plugin? https://wordpress.org/plugins/wp-persistent-login/
Here's tested working code on persisting the login - as seen in https://wordpress.org/plugins/wp-persistent-login/ wp-persistent-login.php:348
essentially, it finds the relevant session, updates it, and then creates a new cookie
add_action( 'wp_login', function($user_login, $user){
//calls into persistent login plugin https://wordpress.org/plugins/wp-persistent-login/
if(!class_exists('WP_Persistent_Login_Manage_Sessions')){return;}
$user_id = $user->ID;
update_user_meta( $user_id, 'persistent_login_remember_me', 'true');
// get the users latest session from the database
$sessions = get_user_meta( $user_id, 'session_tokens', true );
if( is_array($sessions) ) {
// fetch the login time column from the array
$login_times = array_column($sessions, 'login');
// sort the sessions by login times (newest first)
array_multisort( $login_times, SORT_DESC, $sessions );
// get the key (verifier) of the first session
$session_verifier = array_key_first($sessions);
//remove the session from the database
$wp_login_manage_sessions = new WP_Persistent_Login_Manage_Sessions( $user_id );
$wp_login_manage_sessions->persistent_login_update_session( $session_verifier, null );
// set a new cookie with remember me checked
wp_set_auth_cookie( $user_id, true );
}
}, 10, 2 );
I want the plugin to remember the login, just like "Remember Me" option in standard login form.