Created
January 12, 2022 16:12
-
-
Save thisbit/168452c4048efd5ad81ea9f621723eef to your computer and use it in GitHub Desktop.
Hide content field in post, or hide gutenberg from non admins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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