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

In a small plugin I’ve written to add an IP address column to the comments list I want to remove the avatars.
In line 156 I tried to use remove_filter:

remove_filter( 'comment_author', 'floated_admin_avatar', 50 );

Well … I know this function fails sometimes, but why does it fail here?

My workaround is:

$_GET['comment_status'] == 'spam' 
    and add_filter( 'pre_option_show_avatars', '__return_zero' );

I guess I stared too long at this code to see what went wrong. I need a hint into the right direction.

share|improve this question
up vote 3 down vote accepted

As usual with hooks this is issue of timing.

  • your init function is hooked to admin load process, which works fine for most things;
  • however in this specific case function is added to filter in constructor of WP_Comments_List_Table class, and object is created in edit-comments.php after admin loader had been processed.

In my plugin for similar stuff I am removing it at manage_edit-comments_columns hook.

Simplified example from my class:

static function on_load() {

    add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );

static function admin_init() {

        add_filter( 'manage_edit-comments_columns', array( __CLASS__, 'manage_columns' ) );

static function manage_columns( $columns ) {

    remove_filter( 'comment_author', 'floated_admin_avatar' );

    // stuff

    return $columns;
share|improve this answer
May just be my coding but when I use the suggested hook I get an awful lot of php foreach errors. @Rarst could you expand your answer with a code example when you get 5? Thanks :) – studioromeo Jan 22 '12 at 23:44
@studioromeo added example code – Rarst Jan 23 '12 at 9:38
thanks! I totally forgot about the CLASS magic constant looks better than &$this – studioromeo Jan 23 '12 at 21:13

May be its the priority 50. Instead let it be default.

From http://codex.wordpress.org/Function_Reference/remove_filter

$priority (int) (optional) The priority of the function (as defined when the function was originally hooked). Default: 10

So change

remove_filter( 'comment_author', 'floated_admin_avatar', 50 );


remove_filter( 'comment_author', 'floated_admin_avatar');
share|improve this answer
The priority parameter just says in which order to add or remove a filter. I used it without a priority first and this didn't work too. – toscho Dec 29 '11 at 10:34
When removing an action or filter, you must match the priority exactly, to whatever priority the callback was attached. – Mark Duncan Dec 29 '11 at 15:54

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.