Last active
March 19, 2022 19:19
-
-
Save Asikur22/bfce48deb895f275dbc6a21958d4806a to your computer and use it in GitHub Desktop.
Increase WP Login Cookies Time #wp #login #rememberme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For Admin 4months orther 2months | |
add_filter( 'auth_cookie_expiration', function ( $time, $user_id ) { | |
$user = new WP_User( $user_id ); | |
if ( ! empty ( $user->roles ) && in_array( 'administrator', $user->roles, true ) ) { | |
return MONTH_IN_SECONDS * 4; | |
} | |
return MONTH_IN_SECONDS * 2; | |
}, 99, 2 ); | |
// For all user 2months | |
add_filter( 'auth_cookie_expiration', function () { | |
return MONTH_IN_SECONDS * 2; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment