I am trying to set a Post’s 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.
My goal is to ensure posts aren’t accidentally published if the user isn’t ready or forgot to select ‘private’.
I can’t find any code that works for Gutenberg. Most I researched are outdated and for the classic editor. I would prefer not to use a plugin if possible.
Any help is much appreciated. Thanks in advance!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0