• 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);
    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 [https://wiki.www.ads-software.com/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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter briangroce

    (@briangroce)

    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...
    }
    }

    Is it the same still? has the code been fixed?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin/API (add_action(‘publish_post’)’ is closed to new replies.