WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a plugin and having a problem. I have add_action('publish_post', 'sender'); and I want this function to run first before the add_filter function, although it won't. Is there a way to do this? I've tried moving the add_filter below add_action but that doesn't work. Also pasting the add_filter one into the add_action function doesn't work. Thanks for the help.

For example, if this would work it would be great.

  if (add_action('publish_post', 'sender'))

But it doesn't and somehow still runs the add_filter function first.

share|improve this question
Your question doesn't make a lot of sense. add_action and add_filter both just your functions to the hooks to the system, they don't control the order in which hooks are called. – Otto Aug 4 '11 at 19:44
in the normal publishing flow wp_insert_post_data is fired by WordPress before publish_post so I'm not sure thats the way to go, what are you trying to do, maybe we can think of another way – Bainternet Aug 4 '11 at 19:49
Take a look at the has_action() function. – kaiser Aug 4 '11 at 20:13
up vote 3 down vote accepted

It doesn't matter the order in which you call add_action() and add_filter().

What matters is the order in which the corresponding do_action() and apply_filters() are called.

So, if apply_filters('wp_insert_post_data') is run before do_action('save_post'), tough luck. You'll have to think of another way to achieve the desired result.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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