[wp-testers] wp-login.php

Ryan Boren ryan at boren.nu
Sun Mar 16 17:56:53 GMT 2008


On Sun, Mar 16, 2008 at 7:47 AM, an at horttcore.de <an at horttcore.de> wrote:
> Yesterday I'd checked if my plugins still work with WP 2.5,
>  sadly the answer is no. So I had a look at the wp-login page.
>
>  The hook 'wp_authenticate' is still there but I'm unable to return the
>  error.
>  Anyone got a clue, if it is my fault or WPs? Here is the function I
>  have attached to the hook.
>
>  Function cur_authenticate(){
>         global  $user;
>
>                 if (!is_authenticated()) {
>                         $error = '<strong>ERROR:</strong> Your account has to be confirmed
>  by an administrator before you can login';
>                         $user = new WP_Error();
>                         $user->add('error',$error);
>                         return $user;
>                 }
>  }

wp_authenticate is an action, not a filter, so anything that is
returned is discarded.  I'm not sure how the global $user would have
worked either.

2.5 offers a new filter that is more suited to what you are trying to
do: wp_authenticate_user.  Here's how it is used in the code:

        $user = apply_filters('wp_authenticate_user', $user, $password);
        if ( is_wp_error($user) ) {
                do_action( 'wp_login_failed', $username );
                return $user;
        }


More information about the wp-testers mailing list