Probably quite a simple problem.. I have a custom post type with taxonomy terms. I wish to run a function from my functions.php whenever the admin ticks a specific term box.

My original thought was to use add_action along with a "save_post" action so when the post is saved, it would loop through my terms and if the desired one is selected, it would run the function.

This is all good, except each time the admin updates the post it would run the function. The function is sends an email to a user, and I onyl want this email sent out ONCE. Is there any way I can set it so once the function runs it will not run again? I thought about updating a row in the DB and adding a "1" for example when the function runs, and having an if(){} within the fucntion to check if it had been ran before, but this seems like a dodgy way of doing it :/


1 Answer 1


In your emailfunction, check if the date is difrent from the publish date, if so, don't email. This will cause you to email only once?

  • Yeah that would be good but the admin changing the term might change it days or weeks aftert the post was published... only need the email sending once, and only when the admin saves thwe post with a certain term ticked... thanks though :)
    – JamesG
    Commented Aug 21, 2012 at 16:19
  • then your only option would be like you suggest yourself is to keep a value in your database, to check if it was already sent or not.
    – woony
    Commented Aug 22, 2012 at 8:48
  • Ok thanks :) just wanted to see if tjhere was a more.. widely used and accepted way.
    – JamesG
    Commented Aug 22, 2012 at 9:45

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.