Change WordPress user roles and capabilities Forums Give user access to plugin – how to Enable Edit CSS for Administrators in Multisite

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6162
    tracedef
    Participant

    After giving an administrator all capabilities, including edit_css, admins are still unable to edit css via our theme at appearance > customize > custom css …. so only super admins have this access. Any ideas on how to enabled css editing for administrators? Thanks!

    #6163
    Vladimir
    Keymaster

    edit_css together with unfiltered_html are not allowed at WordPress core by default for WP multisite.

    
    case 'edit_css':
    case 'unfiltered_html':
    	// Disallow unfiltered_html for all users, even admins and super admins.
    	if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) {
    		$caps[] = 'do_not_allow';
    	} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
    		$caps[] = 'do_not_allow';
    

    Workaround:
    URE Pro should be network enabled.
    Go to “Network Admin -> Settings -> User Role Editor -> Multisite” tab and turn ON ‘Enable “unfiltered_html” capability’ checkbox.

    #6164
    tracedef
    Participant

    The network activated workaround enabling unfiltered_html in multisite tab didn’t have any effect. Where does the first code you listed go? I tried functions.php to no avail.

    #6165
    Vladimir
    Keymaster

    Code belongs to wp-includes/capabilities.php

    #6166
    tracedef
    Participant

    Thank you. All of our sites break when I add that code to wp-includes/capabilities.php. Is there a special way to insert it? Not sure what I”m doing wrong. Also, this code would likely need to be replaced everytime we update wordpress right?

    #6167
    tracedef
    Participant

    Never mind, the following works in fuctions.php:

    add_filter( 'map_meta_cap', 'multisite_custom_css_map_meta_cap', 20, 2 );
    function multisite_custom_css_map_meta_cap( $caps, $cap ) {
    	if ( 'edit_css' === $cap && is_multisite() ) {
    		$caps = array( 'edit_theme_options' );
    	}
    	return $caps;
    }
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.