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

Is there a built-in function that would allow me to restrict access to registered users until the official launch date in Wordpress 3.4.2? The blog is self-hosted.

share|improve this question
Restrict access to registered users to the entire site, or just the WordPress Dashboard back-end? Do you want to restrict access to everyone? – Rachel Baker Nov 21 '12 at 15:21
Yes I want the entire blog to be accessible only to registered users so the content manager can update it while I finish styling it. – Jane Nov 21 '12 at 15:24
up vote 2 down vote accepted

This should do it. Place it in your theme's functions.php or a plugin.

function tst($a) {
  if (!current_user_can('edit_posts')) {
    wp_die('You are not allowed to view this page');

You can still get to the login page like normal by going to "/wp-login.php" or "/wp-admin".

Alternately, you could use wp_safe_redirect or wp_redirect instead of wp_die to send people to a "Coming soon" page or something like that.

share|improve this answer
Thank you for your help! – Jane Mar 15 '13 at 11:47

There are numerous plugins that do this already. Search Google for:

wordpress restrict site access
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.