0

How to Redirect Buddypress Directories To Login Page For Non Logged in Users?

I'm also using the Yuzify plugin. It gives a code for it, but it's not working on multisite. Can anyone modify this code or provide me with a new code for it?

/**
* Redirect Buddypress Directories To Login Page For Non Logged in Users.
*/
function yzc_redirect_bp_directories_to_login_page() {

    if ( ! is_user_logged_in() && ( bp_is_groups_directory() || bp_is_members_directory() ) ) {
        
        // Get Buddypress Pages;
        $bp_pages = get_option( 'bp-pages' );
        
        // Get Redirection Url
        $redirect_url = youzify_get_login_page_url();
        
        wp_redirect( $redirect_url );
        exit();
    }
}

add_action( 'template_redirect', 'yzc_redirect_bp_directories_to_login_page' );

Thank you.

1
  • what is youzify_get_login_page_url? Have you raised this with Yuzify's support?
    – Tom J Nowell
    Jun 15 at 16:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.