Keep one user logged for a year?

get_currentuserinfo() is a pluggable function, it is not available during plugins load stage.

That aside you shouldn’t be adding filter conditionally, but use data provided by the filter. If you take a look at filter calls:

apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember )

$user_id is provided as second argument. You just have your filter listen for it and modify return conditionally on it.

Here’s an untested example:

add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year', 10, 3 );

function keep_me_logged_in_for_1_year( $ttl, $user_id, $remember ) {
    if( 123 === $user_id )
        $ttl = YEAR_IN_SECONDS;
   return $ttl;
}

Leave a Comment