Title: wp_insert_post() only makes draft
Last modified: August 21, 2016

---

# wp_insert_post() only makes draft

 *  [Ehsaan](https://wordpress.org/support/users/ehsaan/)
 * (@ehsaan)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/wp_insert_post-only-makes-draft/)
 * Hello. I’ve asked this question many places and no one know. Anyone here know
   what the hell is problem?
 * This is my code:
 *     ```
       $post = array(
       			'post_title'		=>	wp_strip_all_tags( $order_details['title'] ),
       			'post_author'		=>	get_current_user_id(),
       			'post_type'			=>	'wp_order',
       			'post_status'		=>	'pending',
       			'post_date'			=>	date( 'Y-m-d H:i:s' ),
       			'post_date_gmt'		=>	date( 'Y-m-d H:i:s' )
       		);
       		$postID = wp_insert_post( $post );
   
       		if ( is_wp_error( $postID ) ) {
       			set_transient( 'wpo_new_order_message_' . get_current_user_id(), __( 'There was a problem to register your order. Please try again later', 'wpo' ) );
       			return;
       		}
       		$post_status_update = array(
       			'ID'			=>	$postID,
       			'post_type'		=>	'wp_order',
       			'post_status'	=>	'pending'
       		);
       		wp_update_post( $post_status_update );
       ```
   
 * This code only creates “Draft” orders, it doesn’t update post date and I can’t
   delete posts those it creates from WordPress.
    Please help me. I’m struggling
   about 3 months on this damned code.

The topic ‘wp_insert_post() only makes draft’ is closed to new replies.

## Tags

 * [wp_insert_post](https://wordpress.org/support/topic-tag/wp_insert_post/)

 * 0 replies
 * 1 participant
 * Last reply from: [Ehsaan](https://wordpress.org/support/users/ehsaan/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/wp_insert_post-only-makes-draft/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
