371 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
PixelStores says

Hey,

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 :)

Matt

1468 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 6 years
  • Has sold $250,000+ on Envato Market
+5 more
fuelthemes says

I use it in my phiyaz theme. When logged in, theme dispays account panel, latest posts. When logged out, displays login/register forms.

http://themeforest.net/item/phiyaz-entertaintment-community-theme/67220

I don’t remember adding any redirection. I think wordpress handles this automatically.

3437 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 4 years
+1 more
organicbee says
371 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
PixelStores says

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. :p

Any ideas?

Cheers

Helpful Information

  • 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.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by