- Using Heading Block
- Buttons
- Post Grid
- Content Timeline
- Social Share
- Google Map
- Add Testimonials
- Info Box
- Section
- Team
- Icon List
- Price List
- Post Masonry
- Post Carousel
- Importing Starter Templates With Spectra
- Post Timeline
- Call To Action
- Advanced Columns
- Troubleshooting: Missing Icons
- Filters/Actions For Post
- Blockquote
- Spectra Patterns
- Contact Form 7: Multiple Column Fields
- Contact Form 7: Checkbox / Radio / Acceptance Control
- Unable To Style Contact Form 7
- Marketing Button
- Tab Index For Multiple Gravity Forms
- Getting Started With Spectra
- Manually Install Spectra Via FTP
- Table Of Contents
- How-to Schema
- FAQ’s: Schema/Accordion
- Inline Notice
- WP – Search
- Exclude Heading From TOC
- Review Schema
- Lottie
- Taxonomy List
- Tabs Block
- Block Display Conditions
- Create Contact Forms
- Import Single Pages, Templates, & Block Patterns
- Enable/Disable Design Library Button
- Update Folder File Permissions
- Assets API For Third-Party Plugins
- Star Rating
- Masonry Image Gallery
- Wireframe Blocks
- Copy & Paste Style
- Coming Soon Mode
- Load Google Fonts Locally
- Container Flex Property
- Default Content Width
- Blocks Editor Spacing
- Heading Block
- Image Block
- Buttons Block
- Translate Everything WPML
- Container Block
- Collapse Panels
- Responsive Conditions
- Taxonomy Styling Options
- Block Presets
- Image Gallery
- Counter Block
- Modal Block
- Registration Form Block
- Dynamic Content Extension
- Slider Block
- Pagel Level Custom CSS
- Countdown Pro
- Slider Custom Navigation
- Instagram Feed
- Loop Builder
- Animations
- Login Form Block
- Site Visibility
- Global Block Style Extension
- Spectra Actions: Clear Cache
- Create Popups
- Quick Action Bar
- Custom Blocks
- Move Block Patterns
- Grid Builder
- Move Title Bar To Top
- Resolving Container Layout Conflicts
- Newsletter Forms
- Register High-Privileged Users
- User Roles Access To AI
- Database Update Instructions (Below 2.0.0)
- FAQ's: VIP Priority Support
- Whitelist Email Address
- Hide Core Blocks
- Regenerate Assets With Code
- Using ACF Repeater Field in Spectra
- Pixabay Image Search Feature
- Â Getting Started with Instagram
- How to Fix Stretched Spectra Images in WordPress 6.7
- How to Change Breakpoints in Spectra?
- Controlling Access to the Spectra Design Library Based on User Roles
- Advanced Loop Builder
- Multi-Column Form Block Using Utility Classes
- Why Am I Seeing Mixed Content or Non-HTTPS Errors?
- Preview Options (Desktop, Tablet & Mobile)
- Transparent / Sticky Header
- Change Site Logo
- Change Global Styles
- Disable Title on Posts & Pages
- Transparent / Sticky Header For Single Page / Post
- Change Header & Footer Patterns
- Custom / Google Fonts
- Reset Global Default Styling
- Manually Install Spectra One Via FTP
- Enable / Disable Header & Footer On Specific Pages / Posts
Controlling Access to the Spectra Design Library Based on User Roles
Spectra plugin provides a rich design library to streamline the website-building process.
By default, access to this library is limited to certain user roles. However, you can customize this access by using a simple code snippet.
This guide demonstrates how to provide access to the Spectra Design Library for users with specific roles, such as ‘editor.’
How to Control Access to the Spectra Design Library Based on User Roles
To grant access to the Spectra Design Library based on user roles, you need to add the following code to your WordPress site.
It is recommended to place this code in your child theme’s functions.php file to avoid losing changes during theme updates:
add_filter( 'ast_block_template_capability_additional_roles', function( $roles ) {
$roles[] = 'editor'; // Add the 'editor' role
return $roles;
});
Explanation of the Code
- Filter Hook: ast_block_template_capability_additional_roles is a filter hook provided by the Spectra plugin to manage access to the design library.
- Callback Function: The anonymous function adds the desired role (editor in this case) to the list of roles allowed access.
- Return Value: The modified $roles array is returned to the filter, enabling the specified role(s) to access the design library.
How to Add the Code
You can follow the below steps to add the code to your WordPress site.
- Log in to your WordPress admin panel.
- Navigate to Appearance > Theme File Editor if adding the code to your theme.
- Alternatively, use a plugin editor or create a custom plugin for the code.
- Add the above code snippet to your child theme’s functions.php file. Using a child theme ensures that your customizations remain intact after theme updates.
- Save the file and verify that the changes are applied.
To test the functionality:
- Log in as a user with the editor role.
- Navigate to the Spectra interface and confirm access to the Design Library.
Important Note: Ensure that you have a backup of your site before making any changes to the code.
If you want to grant access to additional roles, you can add them to the $roles array. For example:
$roles[] = ‘author’;
$roles[] = ‘contributor’;
If you are using a custom role, make sure it is registered in your WordPress setup.
By following this guide, you can easily manage access to the Spectra Design Library for specific user roles, enhancing flexibility and control over your website’s design capabilities.
We don't respond to the article feedback, we use it to improve our support content.