1

Hope I can get some help modifying this php snippet. The snippet redirects all non members that visit my site to the login page. I have a login and registration on mu homepage already and would prefer to redirect all pages to the home page, unless they are on the login, registration, lost-password, or activate page.

    <?php

/**
* Redirect All Site The Login Page For Non-Logged-In Users.
*/
function yzc_redirect_all_site_to_login_page() {

if ( is_user_logged_in() ) {
return;
}

if ( 'off' == get_option( 'yz_activate_membership_system' ) ) {
return true;
}

if ( ! logy_is_page( 'login' ) && ! logy_is_page( 'register' ) && ! logy_is_page( 'lost-password' ) && ! bp_is_activation_page() ) {
$login_page = logy_page_url( 'login' );
wp_safe_redirect( $login_page );
exit();
}

}

add_action( 'template_redirect', 'yzc_redirect_all_site_to_login_page' );

0 Answers0