Disable your Website to Visitors but not Users

January 24, 2011 – 10:27 am |

Occasionally there comes a time when you need to disable your website to visitors, especially if you’re setting up a website for a customer but it is in pre-launch stage.  If you need do that you can drop some code into your header.php file quickly and easily using these instructions:

1. Log in to your WordPress backend and choose ‘Editor’ under ‘Appearance on the left sidebar:

11 Disable your Website to Visitors but not Users

2. Choose Header (header.php) on the right sidebar

2 Disable your Website to Visitors but not Users

3. At to top copy this code and paste it into the file:
<?php if (!is_user_logged_in()) {
exit();
} ?>

3 Disable your Website to Visitors but not Users

4. Click ‘Update File’ when you’re done!

4 Disable your Website to Visitors but not Users

5. To test it out go to your homepage when you’re still logged in then log out and try again!  If it is working properly you’ll see the website when logged in and see a completely blank page when you’re logged out.

5 Disable your Website to Visitors but not Users

6 Disable your Website to Visitors but not Users

6. When you’re finished with your edits just remove this portion of code through the same Editor and click ‘Update File’

pixel Disable your Website to Visitors but not Users