Last active
September 15, 2024 13:29
-
-
Save jazzsequence/4f16932fdc5980c0af43dbdc9bf9aac4 to your computer and use it in GitHub Desktop.
Add `unfiltered_html` capability to editors on 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 | |
/** | |
* Add `unfiltered_html` capability to editors (or other user roles). | |
* On WordPress multisite, `unfiltered_html` is blocked for everyone but super admins. This gives that cap back to editors | |
* and above. | |
* | |
* @author Justin Tadlock | |
* @link http://themehybrid.com/board/topics/add-unfiltered_html-capability-to-editor-role#post-4629 | |
* @param array $caps An array of capabilities. | |
* @param string $cap The capability being requested. | |
* @param int $user_id The current user's ID. | |
*/ | |
function my_map_meta_cap( $caps, $cap, $user_id ) { | |
if ( 'unfiltered_html' === $cap && user_can( $user_id, 'editor' ) ) | |
$caps = array( 'unfiltered_html' ); | |
return $caps; | |
} | |
add_filter( 'map_meta_cap', 'my_map_meta_cap', 1, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It worked for me, @jazzsequence. I tried various approaches and none of them have worked till I stop by your gist. Thank you so much for sharing.