[wp-hackers] Plugin/API (add_action('publish_post')

Brian Groce wp at briangroce.com
Tue Jul 20 17:29:40 UTC 2004


FYI: This is how you can do it...

function your_function() {

         $prev_status = $_POST['prev_status'];
         $post_status = $_POST['post_status'];

         if (isset($_POST['publish'])) $post_status = 'publish';

         if ($prev_status != 'publish' && $post_status == 'publish') {

           Do things here...
                 }
         }

Brian
http://briangroce.com



At 11:00 PM 7/18/2004, Brian Groce wrote:
>Maybe someone can help me here...
>
>I have a plugin which I've setup using the Plugin API as follows:
>
>add_action('publish_post', 'send_notification', 5);
>
>[see: 
>http://www.briangroce.com/archives/2004/07/word-press-email-notification-plugin-v12/]
>
>But I'm having a problem...every time a post is published AND edited, the 
>function runs (thus in this case, sending out an e-mail every time).  It 
>needs to only be ran the first time a post is published.
>
>Looking at the API [http://wiki.wordpress.org/Plugin/API] it states that 
>publish_post is "called when a post status is changed from anything to 
>publish or when a post is published for the first time."
>
> From what I'm seeing it should more accurately read, "publish_post is 
> called when a post status is publish or when a post is published for the 
> first time."
>
>Does anyone know if this is a correct assessment of how it works?  Or am I 
>missing something?
>
>Thanks,
>
>Brian
>http://briangroce.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/hackers_wordpress.org/attachments/20040720/5369b703/attachment.htm


More information about the hackers mailing list