[wp-hackers] updating plugins for compatibility with 2.4.x+

chays whoooo at gmail.com
Mon Feb 4 06:45:45 GMT 2008


jacob,

I think you don't understand my question. let me rephrase it.

Inside wp-login.php there is error checking, for the email address, for the
username, etc..

Like so, and this right out of the SVN:

*if ( $user_login == '' )
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please
enter a username.'));
    elseif ( !validate_username( $user_login ) ) {
        $errors->add('invalid_username', __('<strong>ERROR</strong>: This
username is invalid.  Please enter a valid username.'));
*



For the sake of simplicity, lets pretend I have a plugin that checks that
the username is "jim" and will not allow the user to register unless the
username == Jim.

In *2.3* and below, this was simple:

if ($username != "Jim") //example only
        {
        $errors['deadbolt'] = get_option('deadbolt_message');
}

that was all it took, using only one global.

As you can see, 2.3 and 2.4 dont handle these "errors" the same way.

As far as the hook goes, its already there, has been for some time; its
register_post, and it's for just this purpose.


On Feb 4, 2008 1:34 AM, <wordpress at santosj.name> wrote:

> You are looking the wrong place for the errors. Most of the time when
> errors are encountered, they are redirected. In the process of wp-login,
> you'll want to look in either wp_signon() (pluggable.php??), or
> wp_safe_redirect() for a filter of some kind, or login_header() for a
> filter. If none exist, then I guess the WordPress source doesn't want to
> you see the errors.
>
> There are no other actions or hooks that reference the errors, so I
> suppose you are SOL in WordPress 2.5. You can lobby for them to add an
> action that references the errors before the redirect.
>
> Jacob Santos
>
>
> > Hopefully, someone can tell me where I am going wrong with this?
> >
> > I am in the process of updating my plugins for 2.4.x and beyond, and one
> > of
> > them hooks into register_post (wp-login.php).
> >
> > The old plugin only required one global, $errors, and in keeping with
> how
> > 2.3.x and lower handled them, displaying the error message was only as
> > tough
> > as using: *$errors['plugin'] = get_option('plugin_message');
> >
> > *2.4-bleeding has changed the error stuff to a format like so:
> > *$errors->add('invalid_email',
> > __('<strong>ERROR</strong>: There is no user registered with that email
> > address.'));
> >
> > *I have tried everything under the sun, globalized everything I could
> > think
> > of, $errors, $error, you name it, and made sure that my error message
> > follows the pattern above, and yet for some reason I cannot get WP to
> > "see"
> > my error.
> > I've went so far as to place a *var_dump( $errors ); *after
> > do_action('register_post'); inside wp-login.php, and of course, it sees
> > all
> > the standard errors, but doesnt see the one I'm adding. Yes, the actual
> > checking is working.
> >
> > Am I missing globals? Something else that I need to add? If I take the
> > plugin code and paste it right above the hook, it works -- so I'm
> > obviously
> > missing something.
> >
> > Ideas?
> >
> > Thanks in advance
> >
> >
> > *
> > *
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list