Support » Developing with WordPress » custom post type – that cant publish

  • dabasys


    I am making a plugin with a custom post type.

    But I want to make so that custom post type, cant publish it posts – only save the posts as drafts?

    Is that possible to add that feature to a custom post type?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Subrata Sarkar


    Moderator bcworkz


    Subrata normally has great advice, but I’m going to disagree on this one. The problem with using the “save_post” action is explained in the link, the need to remove your callback before saving the modified post. There’s a better way: use the ‘wp_insert_post_data’ filter instead. Here you can alter post data before it is saved so you don’t need to save it again and remove your callback before doing so.

    Essentially, your callback just needs to set the post status as “draft” for your particular post type no matter what the passed status is. It would be a good idea to at least hide the publish button with CSS so no one will think they are publishing something, their only visible option will be to save as draft.

    You don’t want to just hide the button without setting the post status as draft in ‘wp_insert_post_data’ as well because it’s too easy for users to unhide things hidden with CSS.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom post type – that cant publish’ is closed to new replies.