Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Last active March 19, 2022 19:19
Show Gist options
  • Save Asikur22/bfce48deb895f275dbc6a21958d4806a to your computer and use it in GitHub Desktop.
Save Asikur22/bfce48deb895f275dbc6a21958d4806a to your computer and use it in GitHub Desktop.
Increase WP Login Cookies Time #wp #login #rememberme
// 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