Posted By

ddavidd on 01/05/11


Tagged

redirect wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

qubestream


Wordpress - redirect if you're not logged in


 / Published in: PHP
 

Add this in the functions.php file, in your Wordpress theme.

  1. if(!is_user_logged_in() && $pagenow != 'wp-login.php') {
  2. wp_redirect( '/comingsoon.html', 302 );
  3. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: leond on January 12, 2011

What if the visitor has javascript disabled?

better to do this in the php script; in functions.php file: [code] if( !isuserlogged_in() { header( 'location: http://domain.com/comingsoont.html'); } [/code]

Posted By: ddavidd on April 14, 2011

Thanks leond, I actually really like that idea. Not sure why I didn't do that to begin with.

You need to login to post a comment.