I'd like to check if the server is running PHP5.2. To do this, I use a activation-hook which will be registered with "register_activation_hook". Instead of just returning a warning, i'd like to auto-disable the plugin and redirect to the plugins.php in WP-Dashboard.
Unfortunately, this doesn't work. No error or other output. The activation-hook fires correclty, tested with a wp_die().
What I'm doing wrong here?
register_activation_hook(__FILE__, 'MyActivationHook');
function MyActivationHook() {
if(version_compare(PHP_VERSION, '111.2', '<')) {
deactivate_plugins(plugin_basename(__FILE__));
wp_redirect(admin_url('plugins.php'));
//wp_die(printf(__('Sorry, you need at least PHP version %1s to use this plugin. Your current PHP version is %2s.', 'textdomain'), '5.2', PHP_VERSION));
}
}