Created
January 29, 2018 16:54
-
-
Save Garconis/02b65a0acae7f4bc7ac0c3e33b7ffbe5 to your computer and use it in GitHub Desktop.
WordPress | Redirect pages to the homepage, if the user isn't logged in. Good for maintenance mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// if it's not the homepage and they aren't logged in, redirect to the home URL | |
add_action( 'template_redirect', 'fs_maintance_mode' ); | |
function fs_maintance_mode() { | |
if ( !is_home() && !is_user_logged_in() ) { | |
wp_redirect( esc_url_raw( home_url() ) ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment