I’m providing front-end login in a template, using the function wp_login_form. It handles the redirection after login and logout pretty neatly! But if the username / password mismatch, or are non existent, the user is redirected to the admin login page, with the shaky js error. Also same is the case when I’m trying to reset the password, it takes me to the me backend page where I have to enter my email for resetting the password. I want to show both these activities on my template. Is there a way I could do this?
Thanks for any help in advance.
Yes it’s possible. You have to create three filters for this.
Admin stuff inside a class
First we need to filter the output of the function
wp_login_url()
which is used bywp_login_form()
in the formsaction
attribute.Look at the method
modifyLoginUrl()
. Here we store the URL of the pagelogin
inside the variable$loginUrl
. This page must exists inside WordPress, so create it first.Next we need a filter for the function
wp_lostpassword_url()
andwp_register()
. It’s basically the same. The URL of the site is stored inside the variable$lostpwUrl
and$registerUrl
.Last but not least, you have to call the class on the right action hook. For themes this should be
after_setup_theme
and for plugins you can useplugins_loaded
.Themes / functions.php
Plugins