Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Ehsaan on "wp_insert_post() only creates draft posts"

$
0
0

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 spending about 3 months on this damned code.


Viewing all articles
Browse latest Browse all 8245

Trending Articles