Managing User Roles and Permissions for the Gutenberg Template Library
|
/ Documentation /Custom Code Snippets/ Managing User Roles and Permissions for the Gutenberg Template Library

Managing User Roles and Permissions for the Gutenberg Template Library

You may already be familiar with the Template Kits button available in your Gutenberg editor if you have either Starter Templates or the Spectra plugin installed.

By default, the Template Kits button is accessible only to the website administrator. This ensures a streamlined user experience and prevents unintended actions on your website.

However, we received a few questions from our users about providing Template Kits or Template Library access to specific user groups, such as the Editor role.

We heard your feedback loud and clear, and we’ve created a snippet to help you manage custom capabilities for non-admin user roles.

Granting Full Permissions to Editor Role Users

To grant full permissions to users with the editor role, administrators can use a simple filter.

By adding the following code snippet to their configuration, administrators can extend the capabilities to include the editor role.

add_filter( 'ast_block_template_capability_additional_roles', function ( $roles ) { 

      $roles[] = 'editor';

      return $roles;

   } );

This filter specifically targets the ‘ast_block_template_capability_additional_roles’ hook, allowing administrators to append the ‘editor’ role to the array of roles with additional capabilities.

Adding the Filter to Your Site

Adding this filter to your WordPress site is quite straightforward. Just follow these simple steps:

  • Access the functions.php file within your theme or child theme. You can edit it directly by going to Appearance > Theme file editor or by using any of the code snippet plugins.
  • Copy and paste the provided filter code into the functions.php file.
  • Save the changes to the functions.php file.
  • Make sure that users with the editor role now have full access to the Gutenberg Library, including the visibility of the Template Kits button.

That’s it! Right now, only website admins have full control over the template library. We’ve added ways for other user roles to access parts of it, too.

Now, admins can easily give full access to editors, making it easier for everyone to work on your website or app.

This means you can set things up exactly how you need them, depending on who’s doing what.

Hope this guide helped you. If you have any questions, please feel free to reach out to our support team.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

This field is required.

REWIND

YEAR IN REVIEW

Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form