How to stop execution of a function via add_action hook?
I have the following functions:
function test($post_id){
do_action('test_action',$post_id);
echo $post_id;
}
add_action('test_action',function($post_id){
if ( $post_id == 2 ) //Stop test function execution
}
Using the function hooked to add_action
, how to stop the execution of test()
function without adding any code to test()
. In the above example, if $post_id == 2
, the echo $post_id;
code should not run in test()
.