Created
January 30, 2017 15:30
-
-
Save seventhqueen/e071728dfec33e5108abd954181678e6 to your computer and use it in GitHub Desktop.
Private WordPress community site - redirect guests to register page
This file contains hidden or 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 | |
/** | |
* Restrict users to your site and redirect them to register page | |
* @author SeventhQueen | |
* | |
* @return void | |
*/ | |
function sq_restrict_my_website(){ | |
global $pmpro_pages; | |
if(!is_user_logged_in() && ( function_exists('bp_is_active') && ! bp_is_register_page() ) && $GLOBALS['pagenow'] !== 'wp-login.php' && ( !empty( $pmpro_pages ) && !is_page($pmpro_pages) )){ | |
wp_redirect(wp_registration_url()); | |
exit(); | |
} | |
} | |
add_action('template_redirect', 'sq_restrict_my_website'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment