How to disable a plugin (for example, 2FA) for a specific IP address

If you'd like to disable a plugin (for example, 2FA) for a specific IP address, you can simply remove the plugin from the plugins array in the Roundcube config if a certain condition is met.

Say, you want to disable the x2fa plugin if the user's IP address is "45.133.193.85". To accomplish this, you can add this code to the Roundcube config file (config/config.inc.php) after the $config['plugins'] statement:

if ($_SERVER['REMOTE_ADDR'] == "45.133.193.85") {
    $config['plugins'] = array_diff($config['plugins'], ["x2fa"]);
}

Using this technique you can remove any number of plugins from the plugins array and check for any conditions, for example, checking for multiple IPs or an IP range.