RT @onirismes: Enfin. Le premier numéro d’Onirismes est en ligne ! http://onirismes.com @onirismes #onirismes
RT @Hal_Duncan: Beer beer beer beer! Stouty stouty lovely stout! Beer beer beer beer! Yummy scrummy stouty stout! I can’t hear. Shout it …
There’s nothing like lapsang souchong on a rainy morning.
I spent a long time looking for this and am incredibly relieved to have found it:
http://wordpress.org/support/topic/passing-post_id-to-wp_mail-please-help
I wanted to be able to perform an action (send an email to the site admin) when a certain type of post changed status from draft to published, or, when scheduled for a future date, reached that date and went live on the site. This is not an uncommon task—lots of Twitter crosspost plugins use it. But the internet was not being very forthcoming with the solution. Lots of articles suggest trying to repeatedly check the POST object for different combinations of $_POST[‘post_status’], $_POST[‘original_post_status’] and $_POST[‘prev_status’]. This method is unreliable. Don’t try it.
The much easier way to do it is to use a set of status change action hooks that were introduced as far back as WP 2.3, but have not been very well documented (as is sadly the case with too many obscure action hooks):
add_action('new_to_publish', 'email_notification', 10, 1);
add_action('draft_to_publish', 'email_notification', 10, 1);
add_action('pending_to_publish', 'email_notification', 10, 1);
add_action('future_to_publish', 'email_notification', 10, 1);
Where ‘email_notification’ is the name of the function to be called. Note that these actions pass a single parameter, the $post object.
Filed under wordpress action hooks
It’s been about two weeks. So far I have:
-dropped it out of my shirt pocket and been terrified I broke it
-learned to type ineptly with my thumbs
-been mocked by Notes’ absurd attempts to respell my ‘obscure’ vocabulary
-enjoyed a short story on its tiny screen
-geeked myself silly playing Warlords Classic
-got tired of Angry Birds
-been impressed with how easy it is to interconnect myself (Twitter, FB, PayPal, Google Voice, Dropbox, Dropbox, Dropbox, and I’m good)
-been shocked at how not easy it is to tweet a photo I just took
-been unsurprised at the poor photo quality
-gotten annoyed with the captive-audience-ness of the app store and been tempted to jailbreak
Yea, I have entered Modern Times.