Prevent a plugin from being automatically activated

You might want to add your own plugin to deactivate their plugin (silently). First open their main plugin file and see where the plugin hooks (or filters) in. Then unhook their plugin … and your’s as well.

<?php
/** Plugin Name: Deactivate other plugin */
add_action( 'the_same_hook', 'removeOtherPlugin', PHP_INT_MAX -1 );
function removeOtherPlugin() {
    remove_filter( current_filter(), 'their_function_name' );
    remove_filter( current_filter(), __FUNCTION__ );
}

Explanation

  • The helper to make the removal more portable is current_filter(). It returns the name of the currently running filter.
  • PHP_INT_MAX is PHPs maximum integer (reduced by one), that it automatically adjusted to the OS capabilities. It is the most save method to guarantee that your function is registered later on. If they register their’s afterwards, you still can try to start your function name with a later character like zzzRemoveOtherPlugin or similar.