Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#28789 closed defect (bug) (invalid)

wp_insert_post() only creates draft posts

Reported by: ehsaan's profile Ehsaan Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: General Keywords:
Focuses: Cc:


I use a custom post type (hooked in init) and I've created a form for submitting in front-end and added a hook in init for listening form submitting and then create a post.

Here is my code:

do_action( 'wpo_frontend_before_save_order', $order_details, $user_details );
		$post = array(
			'post_title'		=>	$order_details['title'],
			'post_author'		=>	get_current_user_id(),
			'post_type'			=>	'wp_order',
			'post_status'		=>	'pending'
		$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' ) );

It creates only draft posts, it doesn't update post_date and post_date_gmt too and I can't delete its posts from WordPress (I delete them from database)

I don't know how to fix it. This is a bad problem.

Change History (4)

#1 @MattyRob
10 years ago

  • Resolution set to invalid
  • Status changed from new to closed


Thanks for opening a ticket but the wp_insert_post() function works perfectly well for the core post type and for custom post types registered and accessible in the WordPress admin area.

I suspect there is something wrong in the code you have written and the best place to get help with that is on the forums. (

I'm closing this ticket as invalid but if you can pinpoint a specific issue in the wp_insert_post() feel free to reopen this ticket and provide more details.

#2 @Ehsaan
10 years ago

I'm not sure it is from WordPress or my plugin, Is this bug or something else? But no one know this problem. I thought this is a bug about WordPress. How can I solve it?

#3 @MattyRob
10 years ago


I don't think it's a bug in the core code and therefore think the issue is in your plugin code, open a ticket on the forum and post your full code there or a link to it if it is pretty long and someone may be able to help you.

#4 @DrewAPicture
10 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.