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.
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' );
Hi @wadethefade,
Thanks, that’s great.
I’ll make sure this code is added to the website to help others in the future.