suggest to add function: disable wordpress auto drafts
-
This is a very great plugin! Thank you write it.
I still do not like auto drafts. So suggest to this funtion. Maybe you know or you can know more by Google.I found a method, but need to add code to wordpress core file: wp-admin/includes/post.php.
I have tested it, and really can disable wordpress auto drafts function.
Reference code as follow:open file: wp-admin/includes/post.php,research $create_in_db, and below it:
`$post_id = wp_insert_post( array( ‘post_title’ => __( ‘Auto Draft’ ), ‘post_type’ => $post_type, ‘post_status’ => ‘auto-draft’ ) );
$post = get_post( $post_id );`directly comment above 2 line code, and add under code, so can disable auto drafts function. Detailed code as follow:
`/*
$post_id = wp_insert_post( array( ‘post_title’ => __( ‘Auto Draft’ ), ‘post_type’ => $post_type, ‘post_status’ => ‘auto-draft’ ) );
$post = get_post( $post_id );
*/global $current_user,$wpdb;
$post = $wpdb->get_row( “SELECT * FROM $wpdb->posts WHERE post_status = ‘auto-draft’ AND post_type = ‘$post_type’ AND post_author = $current_user->ID ORDER BY ID ASC LIMIT 1” );
if (!($post) ) {
$post_id = wp_insert_post( array( ‘post_title’ => __( ‘Auto Draft’ ), ‘post_type’ => $post_type, ‘post_status’ => ‘auto-draft’ ) );
$post = get_post( $post_id );
}
`/* End */
Thanks.
- The topic ‘suggest to add function: disable wordpress auto drafts’ is closed to new replies.