How to allow Unfiltered HTML in a wordpress multisite install

This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you on your way.

add_action( 'admin_init', 'my_kses_remove_filters' );
function my_kses_remove_filters() {
    $current_user = wp_get_current_user();
 
    if ( my_user_has_role( 'administrator', $current_user ) )
        kses_remove_filters();
}
 
function my_user_has_role( $role="", $user = null ) {
    $user = $user ? new WP_User( $user ) : wp_get_current_user();
 
    if ( empty( $user->roles ) )
        return;
 
    if ( in_array( $role, $user->roles ) )
        return true;
 
    return;
}

This action removes the filters for administrators. First it gets the role of the current user and if the role is ‘administrator’, it removes the filters on editing content.

This solutions draws heavily from this page.

Leave a Comment