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

chays whoooo at gmail.com
Mon Feb 4 07:03:37 GMT 2008


Heres another example, this might make it even more clear

In 2.3, if I had wanted to check for an email address at registration all
that would have been needed is this:


function email_check() {
        global $errors;
        global $user_email;
        if ($user_email != "secret at secret.org")
        {
        $errors['icky'] = get_option('icky_message');//set elsewhere
        }
        }

A 2.4 equivalent, with the changed error handling:

function email_check() {
        global $error;
        global $errors;
        global $user_email;
        //$errors = new WP_Error;
        if ($user_email != "secret at secret.org")
        {
        //$errors = new WP_Error;
        $errors->add('icky_email', __('<strong>ERROR</strong>: your email
blows.'));
        }
}


 a dump of the array containing the errors AFTER the hook, indicates that
the function is not adding the error to the error array.



















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