Support » Fixing WordPress » Auto sending when “posting”

  • I modified a text message plugin to automatically send a text message (with the contents of the post) when a post is published to my blog.

    I use the “publish_post” hook to call a function that takes in the $post_ID variable. I then get the following information:

    $usepostid = get_post($post_ID);
    $usecat = get_the_category($post_ID);
    $thepoststatus = $usepostid->post_status;
    $theposttype = $usepostid->post_type;
    $thecategoryis = $usecat[0]->cat_ID;

    I then use the following if statement to make sure I am sending only the posts I want.

    if( ($thecategoryis == '3') && ($thepoststatus == 'publish') && ($theposttype == 'post') ){

    Where the category ID I am using is 3. The problem that I am running into is that sometimes when I am editing the post and saving the post it sends out a text message (I think when saving the post). So while editing a post – it will send out the post sometimes 2 times sometimes 5 times.

    I thought using the IF statement above would stop that, i.e. only if the post has a status of publish and type of post?

    Anyone have any thoughts?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Auto sending when “posting”’ is closed to new replies.