I have been searching around for some time now looking for a login form to place in my sidebar.
I want the user to be redirected to the page they have logged in and also display an error message if the Username or Password is incorrect.
Can this be done without a plugin?
Here is a typical login form that redirects the user if he/she has logged in, however if the login details are incorrect the user is redirected to the wordpress login panel /wp-login.php.
<form method="post" action="<?php bloginfo('url') ?>/wp-login.php"> <p> <label for="log"><input name="log" size="22" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" type="text" /> User</label><br /> <label for="pwd"><input name="pwd" size="22" id="pwd" type="password" /> Password</label><br /> <input name="submit" class="button" value="Send" type="submit" /> <label for="rememberme"><input checked="checked" name="rememberme" id="rememberme" value="forever" type="checkbox" /> Remember me</label><br /> </p> <input name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" type="hidden" /> </form>
Any help appreciated
I use it in my phiyaz theme. When logged in, theme dispays account panel, latest posts. When logged out, displays login/register forms.
I don’t remember adding any redirection. I think wordpress handles this automatically.
Cheers guys for your help but unfortunately both login forms redirect the user to wp-login.php from an incorrect user or pass.
@turkhitbox, try logging in with a wrong username or password, you see what i mean.
- Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
- Open a support ticket if you would like specific help with your account, deposits or purchases.
- Item Support by authors is optional and may vary. Please see the Support tab on each item page.
Most of all, enjoy your time here. Thank you for being a valued Envato community member.