WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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:

function wpse56687_filter_everyones_comments(){
      add_filter( 'pre_comment_content', 'wp_filter_kses' );
share|improve this answer
Great - thanks Stephen - that works exactly as needed. – anu Jun 27 '12 at 14:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.