Home / Admin / Add unfiltered_html to editor role
Duplicate Snippet

Embed Snippet on Your Site

Add unfiltered_html to editor role

By default, in a WordPress multisite install, only Super Administrators can have the "unfiltered_html" capability, this snippet allows you to grant that permission to other user roles. https://wordpress.org/documentation/article/roles-and-capabilities/#unfiltered_html

<10
Code Preview
php
<?php
/**
 * Add the unfiltered_html capability to the editor role.
 * Be careful which users you grant this capability to.
 */
add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id ) {
	// Change editor with the user role you want to allow to use unfiltered_html.
	if ( 'unfiltered_html' === $cap && user_can( $user_id, 'editor' ) ) {
		$caps = array( 'unfiltered_html' );
	}
	return $caps;
}, 1, 3 );

Comments

Add a Comment