Restrict Unfiltered HTML to Administrators
Only administrators may save raw HTML such as scripts and iframes in posts. Editors get the same safe HTML filtering as authors.
Opens WPIDE on
Code
add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id ) {
if ( 'unfiltered_html' === $cap && ! user_can( $user_id, 'manage_options' ) ) {
return array( 'do_not_allow' );
}
return $caps;
}, 10, 3 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.