admin管理员组文章数量:1023857
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.
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.
本文标签: phpDisable plugin function to use my own
版权声明:本文标题:php - Disable plugin function to use my own 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745526707a2154557.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论