using wp_signon for a login form in a template
-
I’m trying to create a template in my theme that only shows content to users who are logged in. If the user is not, then he gets a login form.
Here’s the code:
<?php if( !is_user_logged_in() ) { // try loggin them in wp_signon($_POST, true); } if( !is_user_logged_in() ):?> <div class="loginform"> <p>Please enter your username and password to continue</p> <div class="formbox"> <form method="post"> <label for="log">Username:</label> <input type="text" name="log"><br /> <label for="pwd">Password:</label> <input type="password" name="pwd"><br /> <input type="hidden" name="rememberme" value="true"> <input type="submit" value="Log in" name="wp-submit"> </form> </div> </div> <?php else: ?> <div class="pagebody"> <?php // the loop goes here ?> </div> <?php get_sidebar(); ?> <?php endif;
So, the form POSTs the form data back to the same page, where supposedly it is picked up by wp_signon, and the user is logged in.
I’ve searched on Google and these forums, but I can find barely anything on using wp_signon. If anyone could point me towards some examples, or solve my code above that would be absolutely grand.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘using wp_signon for a login form in a template’ is closed to new replies.