I'm adding this filter when the condition is true. Can I add another function on the same filter when the 2nd condition is true or will the last one cancel out the previous one?

    add_filter('wp_insert_post_data', 'save_add_nofollow' );

    add_filter('wp_insert_post_data', 'another_function' );

Hi @Scott B:

Absolutely. That's part of the design of the system, you can add as many as you need (other plugins do.)

The only issue is if you might need to address which one runs first and that's when you may have to set the priority. In the below example the third one would run first and the second one would run last:

add_filter('wp_insert_post_data','norm_priority_func'); // 10=default priority 
add_filter('wp_insert_post_data','run_last_funcn', 11 );  
add_filter('wp_insert_post_data','run_first_func', 9 );  

Of course when you have needs to set priorities you can find it may cause conflict with other plugins that set a priority higher or lower. Typical places where this happens is when you want a hook to run either before or after all others. Are 0 and 100 sufficient priorities? Not if another plugin used -1 and 101; see the quandry? Anyway, that's usually not an issue but when it is, it is.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.