Skip to content

Snippet: Manually Disable WPBakery on Post Types For Specific User Roles

The following snippet can be used to disable access to the WPBakery Page builder on specific post types for users with specific roles. I honestly don't see why this would ever be useful, but it was requested by someone in the past. If you disable access to the WPBakery page builder but the user still has access to edit the post then could mess things up by editing the post without the page builder.

add_filter( 'vc_role_access_all_caps_role', function( $role ) {
	$user_role = 'editor'; // change this to the user role you want to manually enable WPBakery post types for
	if ( empty( $role->name ) && $user_role !== $role->name ) {
		return $role; // security check
	}
	$types = array( 'page', 'post', 'portfolio', 'staff', 'testimonials' );
	foreach ( $types as $type ) {
		unset( $role->capabilities['vc_access_rules_post_types/' . $type ] );
	}
	return $role;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top