[wp-hackers] Best practice: custom registration form

Otto otto at ottodestruct.com
Wed Aug 11 15:48:56 UTC 2010


On Tue, Aug 10, 2010 at 5:46 PM, Lox <lox.dev at knc.nc> wrote:
> If I send a POST to wp-login.php using AJAX, I get an html page in
> response to my request, whereas I just need a valid/invalid flag, an
> array of errors (if any) and a redirect_to var (if redirect is
> needed).

Still not quite following.

If you're doing a login, then you send the log, pwd, and the
redirect_to parameters. What you'll get back on success is a redirect
to your redirect_to page, not HTML.

If you need to intercept that on the back end to check for something
and/or return a different response, then you can use the
login_redirect filter, which gets the redirect_to value as the first
parameter, and the resulting $user object as the second parameter. To
check for a login failure at that point, you'd check for
is_wp_error($user) and if it's true, you can output your error stuff
and then exit() cleanly. No HTML response of any sort then, as far as
I can see.

BTW, since you asked, interim_login is used when a users session
cookies expire. This almost never happens.

-Otto


More information about the wp-hackers mailing list