[wp-hackers] do_action with multiple arguments

Daniel Westermann-Clark daniel at acceleration.net
Thu Mar 10 17:15:42 GMT 2005


Hi,

I've been working on extending the authentication API available to
plugins.  Matt committed my changes yesterday:

http://trac.wordpress.org/changeset/2425

I'm now trying my authentication plugin against trunk, and seem to be
running into an issue related to the changes in issue 901:

http://mosquito.wordpress.org/view.php?id=901
http://trac.wordpress.org/changeset/2398

The do_action function is now passing an empty argument, $string, to
plugin callbacks (line 969 of wp-includes/functions.php).

    $all_args = array_merge(array($string), $args);
    [...]
    $string = call_user_func_array($function_name, $args);

The string is never returned or used outside of do_action, so I'm
wondering about its purpose.  You end up needing to accept an additional
argument than the actual do_action call gives.  Here's a simplified
example from my HTTP authentication plugin:

    add_action('wp_authenticate', 'login', 10, 3);
    function login($string, $username, $password) {
        $username = $_SERVER['REMOTE_USER'];
        $password = $username;
    }

This works, but is the $string argument necessary for actions (as
opposed to filters, where it does make sense)?  I'm probably just
missing something, so I thought it best to ask.

Thanks,
-- 
Daniel Westermann-Clark


More information about the wp-hackers mailing list