Forked from kellenmace/add-unfiltered_html-capability-to-admins-or-editors.php
Created
April 29, 2022 18:52
-
-
Save ivcreative/d19a249845510e315716db727062a574 to your computer and use it in GitHub Desktop.
Add unfiltered_html Capability to Admins or Editors in WordPress Multisite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enable unfiltered_html capability for Editors. | |
* | |
* @param array $caps The user's capabilities. | |
* @param string $cap Capability name. | |
* @param int $user_id The user ID. | |
* @return array $caps The user's capabilities, with 'unfiltered_html' potentially added. | |
*/ | |
function km_add_unfiltered_html_capability_to_editors( $caps, $cap, $user_id ) { | |
if ( 'unfiltered_html' === $cap && user_can( $user_id, 'editor' ) ) { | |
$caps = array( 'unfiltered_html' ); | |
} | |
return $caps; | |
} | |
add_filter( 'map_meta_cap', 'km_add_unfiltered_html_capability_to_editors', 1, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment