How can I override add_filter of a plugin?
like
add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 10, 4 );
I want to use my custom function instead “cart_switching_currency” function.
How can I override add_filter of a plugin?
like
add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 10, 4 );
I want to use my custom function instead “cart_switching_currency” function.
Filters come with a priority parameter, the default is 10, so to override a function you need to increase the priority:
add_filter( 'wcml_switch_currency_exception', 'cart_switching_currency', 99, 4 );
add_filter( string $tag, callable $function_to_add, int $priority =
10, int $accepted_args = 1 )
More info in the add_filter
Update:
If removing a filter is not working you may try this approach:
function remove_cart_switching_currency_filter(){
remove_filter('wcml_switch_currency_exception', 'cart_switching_currency', 10, 4);
}
add_action( 'after_setup_theme', 'remove_cart_switching_currency_filter' );
Important is that the priorities must match.
More info about after_setup_theme