Last active
December 4, 2023 15:21
-
-
Save KaineLabs/247c696d37acd001bfb53bf44e4024e2 to your computer and use it in GitHub Desktop.
Redirect Buddypress Directories To Login Page For Non Logged in Users.
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 | |
/** | |
* 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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nothing is works for me. Can you help me pls