366 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Has been a member for 4-5 years
  • New Zealand
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
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

1302 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 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.

3173 posts
  • Sold between 5 000 and 10 000 dollars
  • United States
  • Bought between 10 and 49 items
  • Has been a member for 4-5 years
  • Exclusive Author
organicbee says
366 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Has been a member for 4-5 years
  • New Zealand
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
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

by
by
by
by
by
by