Showing posts with label Login Page. Show all posts
Showing posts with label Login Page. Show all posts

Saturday, October 8, 2011

Redirect to Login Page in Wordpress

Using PHP, you can use the following code to redirect a user to the log-in page before being able to access a page. It will go to the page the user is trying to access once he is logged-in.

<?php auth_redirect() ?>

Some say it doesn't work right for logged-in users.
Better add a checking just to make sure it works all the time:

<?php
  if ( !is_user_logged_in() ) {
    auth_redirect();
  }
?>