Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I think this may be more of a general php question but I am posting it here as it relates to a WP function. I am having some issues with an add_action on manage_posts_custom_column inside a class. Here is the code (stripped a little):

class The_class{

    function __construct() {
        $this->add_actions();
    }

    function add_actions() {
        add_action('admin_notices', array($this, 'admin_notices'));
        add_action('manage_posts_custom_column', array($this, 'manage_post_columns', 10, 2));
    }

    function admin_notices() {
    // Works fine
    }

    function manage_post_columns($column_name, $post_id)
        switch ($column_name) {
            case 'xxxyyzz':
                // The code                                 
            break;      
            default:
                // Error
            break;
        }   
    }
}

The error I am getting is Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in xxx/wp-includes/plugin.php on line 405.

Looking deeper I found that the action manage_posts_custom_column is referenced in the WP_Posts_List_Table class that extends WP_List_Table and I wonder if this is the cause of the error?

How do I get around this?

Edit:

Well for starters I could write the action properly!!! Instead of add_action('manage_posts_custom_column', array($this, 'manage_post_columns', 10, 2)); it should be add_action('manage_posts_custom_column', array($this, 'manage_post_columns'), 10, 2);. Note the position of the ). :-)

share|improve this question
    
Helped, but close voted as typos won't help. –  kaiser Apr 17 '12 at 1:36
    
Thanks Kaiser! Now can you also delete it entirely :-) –  Niels Apr 17 '12 at 5:02
add comment

closed as too localized by kaiser, toscho Apr 17 '12 at 2:05

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 2 down vote accepted

Your problem is a simple typo:

array($this, 'manage_post_columns', 10, 2)

VS.

array($this, 'manage_post_columns'), 10, 2

I guess you see the difference

share|improve this answer
add comment

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