• Resolved shemakeswebsites

    (@shemakeswebsites)


    Hi, I’m having an issue with a duplicate notification that is being sent on a “pending” status of a custom type posting. My site is still in development stages so it’s not accessible by the public. Please help.

    Thank you.

Viewing 5 replies - 16 through 20 (of 20 total)
  • But now the post doesn’t actually move off “draft”. :X

    I ended up manually updating the status, and then doing wp_transition_status

    
    $theId = wp_insert_post($articleToPost); 
    $postToTransition = get_post( $theId );
    $wpdb->update($wpdb->posts, array('post_status' => 'pending'), array('ID' => $postToTransition->ID));
    wp_transition_post_status( "pending", "draft", $postToTransition );
    

    Getting one notification.

    Thank you for your direction and inputs.

    Plugin Author bnfw

    (@voltronik)

    Hi @wadethefade,
    Not a problem. Glad you got it working.

    Would you mind sharing your complete code snippet here so that it may help others in the future?

    Sure! Glad to help.

    No matter how you get the data, all you need to do is make sure you use the built in WP hooks.

    
    //WP Post Array
    $articleToPost = array(
    'post_title' => $post_title,
    'post_content' => $post_content,
    'post_category' => $cat, 
    'post_status' => "draft", // Choose: publish, preview, future, etc.
    'post_type' => $post_type // Use a custom post type if you want to
    );
    //WP insert post
    $theId = wp_insert_post($articleToPost);
    $postToTransition = get_post( $theId ); // Might not need this
    //Manually Update Post Status. This can be draft to _whatever_				
    $wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $postToTransition->ID));
    clean_post_cache($postToTransition->ID); //Might not need this
    //WP transition post. Make sure this is matches what you did above. This is what BNFW "listens to" to fire a notification.
    wp_transition_post_status( "publish", "draft", $postToTransition );
    

    I did not need to add the add_filter( 'bnfw_trigger_insert_post', '__return_true' );

    Plugin Author bnfw

    (@voltronik)

    Hi @wadethefade,
    Thanks, that’s great.

    I’ll make sure this code is added to the website to help others in the future.

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Duplicate Notifications’ is closed to new replies.