0

I am trying to set a Posts default visibility to 'private' when a user first creates the post. They should then have the ability to manually select 'published' from the sidebar dropdown once they are ready or the post has been reviewed.

The goal is to ensure posts aren't accidentally published if the user isn't ready or forgot to select 'private'.

I have been searching over the internet and cant seem to find any code that works for Guttenberg. Most threads are outdated and seem to be for the classic editor. I would prefer not to use a plugin if possible.

Any help is much appreciated. Thanks in advance!

New contributor
Bmillerz is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
8
  • You can also adjust the pre-publish checklist panel instead, or the classic method of using the contributor role so that posts have to be approved to be published. Also note that this means there will be no draft posts, no review approval, and no scheduled publishing available, as well as no way to know the difference between private posts and posts that haven't been published yet – Tom J Nowell Apr 8 at 12:38
  • Thanks Tom. Unfortunately Contributors are unable to edit published posts so this wont work for my use case. Having the pre-publish checklist does help, however this still does rely on the user manually changing the status. I would prefer for it to default to 'private' automatically to ensure there is no accidental publishing. – Bmillerz Apr 8 at 13:02
  • or having a checkbox that users must check in the pre-publish pane before publishing can happen? Setting the post to private by default isn't an easy thing to do, it's likely you can't find any examples because it has not been done before and requires in depth knowledge that's rare in the WP ecosystem. I can think of a solution but it would make all posts private all the time, even published posts would be turned into private posts, the initial part of the question complicates things greatly. Otherwise the concern you're trying to address is already addressed by lots of other solutions – Tom J Nowell Apr 8 at 13:29
  • also have you considered tweaking the capabilities assigned to the author and contributor roles to allow them to edit other authors posts? – Tom J Nowell Apr 8 at 13:30
  • I've conducted some research into the problem and the results are not good. It may be easier to replace the publish button with a button that prompts the user asking if they are sure they want to publish – Tom J Nowell Apr 8 at 13:46
0

At the time of writing, there are no filters on the initial edits array passed from PHP through to javascript and into the editor initialisation function.

If such a filter existed, it would be possible to apply a post_status field, but no PHP or JS hooks exist currently to do this.

The Editor component also provides no opportunities to modify this structure to add/edit values.

2

Your Answer

Bmillerz is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.