I have copied a function from a plugin because I intend to run the same function with some minor changes. So, to prevent the plugin function running and also mine, I am trying to disable the plugins function.
Plugin function code
/* new product */
function um_activity_new_woo_product( $post_id ) {
....
}
add_action('save_post', 'um_activity_new_woo_product', 99999, 1 );
I thought to try the below, but has not stopped the function from running:
add_filter( 'um_activity_new_woo_product', '__return_false' );
Any ideas or changes to try?
I have copied a function from a plugin because I intend to run the same function with some minor changes. So, to prevent the plugin function running and also mine, I am trying to disable the plugins function.
Plugin function code
/* new product */
function um_activity_new_woo_product( $post_id ) {
....
}
add_action('save_post', 'um_activity_new_woo_product', 99999, 1 );
I thought to try the below, but has not stopped the function from running:
add_filter( 'um_activity_new_woo_product', '__return_false' );
Any ideas or changes to try?
Share Improve this question asked May 3, 2019 at 17:06 wharfdalewharfdale 3484 silver badges17 bronze badges1 Answer
Reset to default 2You can use remove_action()
to remove a function from a specified action hook. Documentation
remove_action( string $tag, callable $function_to_remove, int $priority = 10 )
This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute.
So in your case,
// Remove the function from 'save_post' action
remove_action('save_post', 'um_activity_new_woo_product', 99999 );
// Add your own function my_activity_new_woo_product(), to 'save_post' action
add_action('save_post', 'my_activity_new_woo_product', 99999, 1 );
I hope this may help.