add_filter missing argument when called from inside a class (1 post)

  1. Glenn Ansley
    Posted 7 years ago #

    Hi I'm calling the following from the constructor method inside a class:

    add_action( 'manage_users_custom_column' , array( $this , 'add_column_to_users_table') );

    Below is the (empty) method of the class that its referencing

    function add_column_to_users_table( $column , $user ){ }

    If I add this action from outside the class, everything is legit.
    If I add this action from inside the constructor, I get the "missing argument two" error.

    I thought it might be a problem with variable scope, so I added global $user to the constructor before the add_action function is called... still no dice.

    The only way I've been able to resolve it is by changing the function in the following manner:

    function add_column_to_users_table( $column , $user='' ){
      if ( $user == '' ){ global $user; $user = $user['ID']; }

    is this kosher or is there a better way to take care of this? Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic