• I need help trying to understand how do_action works. I am trying to modify the login function of WordPress. I’m looking for the do_action(‘wp_authenicate’, array(&user_login &user_pass));

    But I can’t find a reference to it anywhere. I know it has something to do with filters, but I can’t locate in the code where authentication happens. Please help.

    Code of do_action

    function do_action($tag, $arg = ”) {
    global $wp_filter;
    $extra_args = array_slice(func_get_args(), 2);
    if ( is_array($arg) )
    $args = array_merge($arg, $extra_args);
    else
    $args = array_merge(array($arg), $extra_args);

    merge_filters($tag);

    if ( !isset($wp_filter[$tag]) ) {
    return;
    }

    foreach ($wp_filter[$tag] as $priority => $functions) {
    if ( !is_null($functions) ) {
    foreach($functions as $function) {

    $function_name = $function[‘function’];
    $accepted_args = $function[‘accepted_args’];

    if ( $accepted_args == 1 ) {
    if ( is_array($arg) )
    $the_args = $arg;
    else
    $the_args = array($arg);
    } elseif ( $accepted_args > 1 ) {
    $the_args = array_slice($args, 0, $accepted_args);
    } elseif ( $accepted_args == 0 ) {
    $the_args = NULL;
    } else {
    $the_args = $args;
    }
    $string = call_user_func_array($function_name, $the_args);
    }
    }
    }
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • wp_authenicate isn’t a function, just a trigger that can be used for a plugin.

    wp_login() (in pluggable.php) is what WordPress uses for the authentication.

    Thread Starter phibertek

    (@phibertek)

    What I don’t understand is how is this a trigger for wp_login in pluggable.php. A little further down in the code (wp-login.php)it actually calls wp_login directly. Can you help me understand this? I would like to pass WP an already encrypted string.

    do_action(‘wp_authenticate’, array(&$user_login, &$user_pass));
    ….
    ….
    ….

    if ( wp_login($user_login, $user_pass, $using_cookie) ) {
    if ( !$using_cookie )
    wp_setcookie($user_login, $user_pass, false, ”, ”, $rememberme);
    do_action(‘wp_login’, $user_login);
    wp_redirect($redirect_to);
    exit;
    } else {
    if ( $using_cookie )
    $error = __(‘Your session has expired.’);
    }
    }

    -Phibertek

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    What I don’t understand is how is this a trigger for wp_login in pluggable.php.

    It’s not. wp_authenticate is an action, but it’s there as a hook for plugins. It’s not used anywhere in WordPress itself.

    What exactly is it that are you trying to do? It sounds like you’re looking at a lot of irrelevant code for your purposes.

    Thread Starter phibertek

    (@phibertek)

    I’m trying to bypass the login feature of WordPress and making it automatic. Once a user is logged into another application, it logs them into WP without being challenged. Unfortunately, the password that I am passing is already encrypted md5(). So, I want to change wp-login.php to disable encrypting it again, rather just compare the hashed strings.

    -Phibertek

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Okay, but wp_login is one of the pluggable functions. That means you can simply replace the function entirely with whatever you like, in a plugin.

    So just make a normal WordPress plugin and in there, create a function called wp_login. And presto, your wp_login will override the built in one. Simple, eh?

    Edit: Actually, looking at 2.1.3, this sort of functionality appears to already be built in. If you’re on the same site, you can just double md5 hash the password, put it in WordPress’s normal cookie, and you should be immediately logged in.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘do_action’ is closed to new replies.