Set Short Automatic Logout Time for One User

One approach can be to log the time a user is logging in at by using:

function user_last_login($user_login, $user) {
   update_user_meta($user - > ID, 'last_login', time());
}
add_action('wp_login', 'user_last_login', 10, 2);

and then checking if the time is passed:

add_action('get_header', 'processOnPageLoad', 1 );
add_action('admin_init', 'processOnPageLoad', 1 );
function processOnPageLoad() {
if( is_user_logged_in() && condition_to_check_required_user ) {
      $last_login_time = get_the_author_meta('last_login');
        $allowed_time = 5 * 60; // This will be 5 minutes in seconds
        if (time() > ($last_login_time + $allowed_time)){
            wp_logout();
            wp_redirect( wp_login_url() );
        }
}
}

Please replace the required condition to check the current user, I haven’t checked the code but this should do the trick.

This code will not work right after copy-paste you will need to specify the condition to check.

The above code will logout the user after 5 minutes of logging in.

error code: 523