Created
September 12, 2012 13:40
-
-
Save jlittlejohn/3706676 to your computer and use it in GitHub Desktop.
WP: Login Logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// is the user logged in? | |
if (is_user_logged_in()) { | |
// you could also add other parameters here to limit who has access to the page: | |
// if (is_user_logged_in() && is_author()) { | |
?> | |
<!-- Code here --> | |
<?php | |
} else { | |
// they aren't logged in, so show them the login form | |
?> | |
You need to log in to access this content. | |
<form name='loginform' id='loginform' action='<?php bloginfo('url'); ?>/wp-login.php' method='post'> | |
<p> | |
<label>Username<br /> | |
<input type='text' name='log' id='log' value='' size='20' tabindex='1' /> | |
</label> | |
</p> | |
<p> | |
<label>Password<br /> | |
<input type='password' name='pwd' id='pwd' value='' size='20' tabindex='2' /> | |
</label> | |
</p> | |
<p> | |
<label> | |
<input name='rememberme' type='checkbox' id='rememberme' value='forever' tabindex='3' /> | |
Remember Me</label> | |
</p> | |
<p class='submit'> | |
<input type='submit' name='submit' id='submit' value='Login »' tabindex='4' /> | |
<?php //use a hidden field to return them to the page they came from ?> | |
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER["REQUEST_URI"]; ?>" /> | |
</p> | |
</form> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment