Make WordPress process admin group comments using $allowedtags

WP uses $allowedtags to limit the set of allowable tags for comments.However, comments from administrators are unfiltered.

What’s the easiest way to ensure admin comments are also constrained to the tags contained in $allowedtags?

Solutions Collecting From Web of "Make WordPress process admin group comments using $allowedtags"

kses_init is hooked onto the init hook with default priority, and (after first removing any of the kses filters) adds filters which strip out tags (wp_filter_post_kses for posts and wp_filter_kses for comments) if the user does not have the capability ‘unfiltered_html’.

Since the capability determines whether or not the user can post ‘unfiltered_html’ comments and posts – you probably don’t want to just remove that capability.

Instead, hook onto init, after kses_init, say with priority 20, and re-add the filters which strip out tags not in the $allowedtags whitelist:

add_action('init','wpse56687_filter_everyones_comments',20);
function wpse56687_filter_everyones_comments(){
      add_filter( 'pre_comment_content', 'wp_filter_kses' );
}