Extending auth_cookie_expiration based on user role

Untested, but the following should only change the expiration time for admins who select ‘remember me’.

function wpse108399_change_cookie_logout( $expiration, $user_id, $remember ){
    if( $remember && user_can( $user_id, 'manage_options' ) ){
        $expiration = 60;// yes, I know this is 1 minute
    }
    return $expiration;
}
add_filter( 'auth_cookie_expiration','wpse108399_change_cookie_logout', 10, 3 );

Leave a Comment