add_action with publish_post?
-
I am attempting to run a function anytime someone publishes a post. I have written a few other plugins but nothing dealing with and add_action and the publish_post. To create a quick demo I created a new plugin and activated it. The plugin contains a simple email bit right out of a codex example. The plugin contain this….
function email_me($post_ID) { $friends = '[email protected]'; mail($friends, "Blog Post", 'New blog post has been submitted.'); return $post_ID; } add_action ( 'publish_post', 'email_me' ); //should trigger function on publish post
I was thinking that this would simple fire off an email each time a post was published. But it doesn’t. No error, nothing happens. I have been thinking about this for a while and I am not sure why it doesn’t. Is it because the plugin doesn’t ever really publish a post within the plugin? Is there something else I need to add to the plugin to make the connection to a post being published?
My goal is to simply have a function run with each post published. If someone can point me in the right direction that would be great.
Cheers.
- The topic ‘add_action with publish_post?’ is closed to new replies.