Skip to content

Instantly share code, notes, and snippets.

@thisbit
Created January 12, 2022 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thisbit/168452c4048efd5ad81ea9f621723eef to your computer and use it in GitHub Desktop.
Save thisbit/168452c4048efd5ad81ea9f621723eef to your computer and use it in GitHub Desktop.
Hide content field in post, or hide gutenberg from non admins
<?php
// this snippet extends the acf ability to hide content field with user based condition
// usecase: if a layout of posts_type is built with gutenberg,
// but one wants editor user group to not touch it while being able to inpt data via ACF fields
// use this in conjunction with acf shortcodes in the gutenberg layout
// this way admin can adapt and change layouts with ease making sure edtors do not interact with layouts
function thisbit_remove_post_type_support() {
remove_post_type_support( 'post', 'editor' );
}
if( ! current_user_can('administrator') ) {
// Hide gutenberg from others.
add_action( 'init', 'thisbit_remove_post_type_support' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment