Enabling SmartSlider3 Support for the Editor Role

By default, the SmartSlider3 plugin only allows administrators to create/edit/delete sliders. In many cases, administrators may want to grant editors the ability to manage sliders. To do that, the following code can be placed in the active theme’s functions.php file (or in a plugin).

/** 
 * Give editors access to SmartSlider3
 * 
 * @see: https://developer.wordpress.org/plugins/users/roles-and-capabilities/
 * @see: https://smartslider.helpscoutdocs.com/article/1983-how-to-give-access-to-smart-slider-for-non-admin-users
 */
function ch_smart_slider_caps() {
	$role = get_role( 'editor' );

	$role->add_cap( 'smartslider', true );
	$role->add_cap( 'smartslider_config', true );
	$role->add_cap( 'smartslider_delete', true );
	$role->add_cap( 'smartslider_edit', true );
	$role->add_cap( 'unfiltered_html', true );
}
add_action( 'init', 'ch_smart_slider_caps', 11 );

Please note: the “unfiltered_html” allows unfiltered HTML to be saved to the database by any users with this capability. By default, WordPress only gives that capability to administrators. This code gives that capability to users editors as well.

Posted in , ,

Leave a Comment

Your email address will not be published. Required fields are marked *