Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following code that generates a login form for every page in my blog.

<form action="<?php echo wp_login_url(); ?>" method="post">
username: <br />
<input name="log" id="login_username" type="text" />
<br />
password: <br />
<input name="pwd" id="login_password" type="password" />
<br />
<br />
<input name="rememberme" id="rememberme" type="checkbox" value="forever" />
remember me
<br />
<br />
<input type="submit" value="login" />
<input type="hidden" name="redirect_to" value="/" />
<input type="hidden" name="testcookie" value="1" />
</form>

But it doesn't work. It just lands the user in login page. I'm wondering if I have left out a part of the form!

SOLVED: I should've just put a hidden input in the form with name of login and some value like true.

share|improve this question
1  
Please post your solution as a separate answer and mark it as "the" answer for future reference. –  EAMann Jan 24 '12 at 17:31
add comment

2 Answers

If you read the documentation on wp_login_url, you can specify a redirect URL without having to use that hidden input field. Alternatively, you could just use the wp_login_form function to do exactly what you want:

<?php wp_login_form(); ?> Just toss that in there in place of your form, and read the documentation on that function to learn how to customize it.

share|improve this answer
3  
+1 for wp_login_form(). See also: wp_loginout(). –  Chip Bennett Jan 24 '12 at 16:40
    
I knew about the wp_login_form() but I needed that code to work. It appears even the wp_login_form() doesn't work either. It seems the problem is elsewhere. –  Hamed Momeni Jan 24 '12 at 16:52
    
Thanks, I found the solution. –  Hamed Momeni Jan 24 '12 at 17:07
add comment
up vote 2 down vote accepted

I should've just put a hidden input in the form with name of login and some value like true.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.