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

I want to create a plugin to sanitize comment and mainly the url field before display only (not before adding to database), to filter the url fields and only allow displaying this field only if it contains specific data, otherwise I want to replace this url field with something safe or clear it.

( i do not want users to enter the url as "test.com" or "example.com" , i want to remove it in these cases)

How can I do that, which filter do i need to add to ?


based on the selected answer, I created this plugin to reset all urls to empty strings:

Plugin Name: Get rid of websites before display
function my_custom_remove_website( $comments ) {
    foreach ($comments as $k => $comment) {
        $comments[$k]->comment_author_url = "";
    return $comments;
add_filter( 'comments_array', 'my_custom_remove_website' );

Please feel free to comment or answer if this plugin is not done with best practices.

share|improve this question
up vote 1 down vote accepted

You might want to check out the comments_array filter.

In 3.5, it is applied in Line 891 of wp-includes/comment-template.php:
$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );

share|improve this answer
Thanks, it worked, I created a plugin based on your input, I posted it above in my question, please feel free to comment if there is something wrong in the plugin I made. – sharp12345 Mar 12 '13 at 16:45

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.