Warm tip: This article is reproduced from serverfault.com, please click

How do you remove or change the functionality of the Publish button on a custom WordPress post?

发布于 2013-02-16 16:12:21

I have a custom post type and need keep the post status from getting set to 'Published' when you click the Publish button. Instead, it should work like the Save Draft button. So I either need to figure out how to just remove the Publish button so the user's can only click Save Draft our preferably, update the Publish button functionality so it doesn't set the post to publish.

Questioner
Ben Marshall
Viewed
0
Ben Marshall 2013-02-18 06:56:08

@PhoenixWing156 was close but one little change so the the other post types get updated as usual.

function dont_publish( $data , $postarr ) {  
  if($data['post_type'] == 'custom_post_type') {
    $data['post_status'] = 'draft';   
  }
  return $data;   
}  

add_filter('wp_insert_post_data' , 'dont_publish' , '99', 2);