I'm trying to do some stuff when a post has been saved, I'm currently using the save_post action, of which generally works.

However, the problem I'm having is when a post is scheduled it fires the save_post action, of which changes some data I don't want it to.

Is there an action of which fires only when the user clicks publish / save in the post edit screen, and not when a post changes schedule status.

2 Answers 2


Check if ( defined( 'DOING_CRON' ) && DOING_CRON ), which will be true if the post save is triggered during a scheduled cron job.

  • Much better... ;)
    – gmazzap
    Sep 25, 2013 at 14:20
  • Ah, good effort. Figures that this would be triggered from a CRON, thanks for this solution. :-) Sep 26, 2013 at 8:15

Ah, so I've sorted this out myself.

I'm not using a different action, however as my functionality is based on Advanced Custom Fields, I've added a condition to only execute certain parts of my code when the $_POST['fields'] variable exists.

Now scheduled posts don't mess my custom data when they go live.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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