WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to restrict access to my WordPress site to allow registered users only. I have tried the following plugins:

  • Require-login
  • Authenticator
  • WP-lock

All of them have the same problem: After seeing the login page, you can easily retype the URL in the browser address bar to bypass the login screen and access the home page directly, without needing to login. Only the home page can be accessed in this way. Clicking on any menus, will take you back to the login screen.

I suspect there is a problem with my site, not the plugins.

I have the following active plugins:

  • Advanced Custom Fields
  • Akismet
  • Analytics360
  • Custom Post Templates
  • Custom Post Type UI
  • Disqus Comment System
  • Duplicator
  • Easy Tweet Embed
  • Email This Page
  • Google Analytics
  • Gravity Forms
  • HotSpots
  • List category posts
  • Mini twitter feed
  • Peter's Login Redirect
  • Select Q&A - WordPress Questions and Answers Plugin
  • Raw HTML
  • Relevanssi
  • Revision Control
  • Swiftype Search
  • ThreeWP Activity Monitor
  • Usernoise Pro
  • W3 Total Cache
  • WP-Lock
  • WPML Multilingual CMS

Any help would be much appreciated, thanks.

share|improve this question
up vote 1 down vote accepted

It seems to me that all you should need is this:

function force_login_wpse_89581() {
  if (!is_user_logged_in()) wp_safe_redirect(wp_login_url());

That should force users to the login page except for users who have already logged in.

I don't know what bells and whistles those plugins provide that my solution does not. Maybe you need something more complex.

share|improve this answer
This code does what you require, if I understand you. 1) Visitors who are not logged in are sent to the login page. 2) Visitors who are logged in can visit the site as normal. – s_ha_dum Mar 6 '13 at 3:29

You should check out the Force Login plugin; it's lightweight, simple, and does exactly what you want to do.

share|improve this answer

Your Answer


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.