Support » Plugin: Code Snippets » Restrict gutenber category widget based on user role

  • Resolved horrigmo


    Hey guys,

    Any good snippets for hiding the “category” widget box for certain user roles when posting?

    I want my users with the “author” capability to only be able to post in ONE category.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge


    This should do the trick:

    add_action( 'add_meta_boxes', function () {
    	$user = wp_get_current_user();
    	if ( in_array( 'author', (array) $user->roles ) ) {
    		remove_meta_box( 'categorydiv', 'post', 'side' );
    } );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.