Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Irakli lagvilava

Quick Add

Hello
When using “Quick Add” I make post as draft, how make default as publish ?

10 months ago
Stefan
Developer

We don’t have a specific hook to do that, but since we use the wp_insert_post method on one of our custom ajax calls, you could use one of the default WordPress hooks. The following snippet will set the post status to publish when it was created by the quick add feature.

function ac_set_published_on_quick_add( $postID ) {
	// Check fo the Quick Add ajax call
	if ( 'acp_add_new_inline' !== filter_input( INPUT_POST, 'ac_action' ) ) {
		return;
	}

	// Remove hook again, otherwise it will loop endlessly 
	remove_action( 'wp_insert_post', 'ac_set_published_on_quick_add', 10 );

	// Set post status to Publish
	wp_update_post( array(
		'ID'          => $postID,
		'post_status' => 'publish',
	) );
}

add_action( 'wp_insert_post', 'ac_set_published_on_quick_add', 10 );
9 months, 4 weeks ago

You must be logged in to reply to this topic.