Remove action from plugin on other plugin

There are two things that confuse people when trying to remove a hook:

  1. The remove_action() or remove_filter() calls must take place after the add_action() or add_filter() calls, and before the hook is actually fired. This means that you must know the hook when the calls were added and when the hook is fired.
  2. The remove_action() or remove_filter() calls must have the same priority as the add_action() or add_filter() call

If these hooks were added on the init filter at the default priority, then to remove them, we’d simply hook into init at a priority later than 10 and remove them.

add_action( 'init', 'wpse_106269_remove_hooks', 11 );
function wpse_106269_remove_hooks(){
    remove_action( 'sportspress_before_single_player', 'sportspress_output_player_details', 15 );
    remove_action( 'sportspress_single_player_content', 'sportspress_output_player_statistics', 20 );
}

From https://codex.wordpress.org/Function_Reference/remove_action

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.

Leave a Comment