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' ); |
the code didnt work
this is the solution that worked for me
`/**
-
Redirect Buddypress Directories To Login Page For Non Logged in Users.
*/
function yzc_redirect_all_site_to_login_page_page_except_home_page() {if ( is_user_logged_in() || 'off' == get_option('youzify_activate_membership_system') ) {
return;
}if ( is_home() || is_front_page() ) {
return;
}if ( !youzify_is_membership_page( 'login' ) && !bp_is_register_page() && !youzify_is_membership_page( 'lost-password' ) && !bp_is_activation_page() ) {
$login_page = youzify_membership_page_url( 'login' );
wp_safe_redirect( $login_page );
exit();
}
}
add_action( 'template_redirect', 'yzc_redirect_all_site_to_login_page_page_except_home_page' );
`
nothing is works for me. Can you help me pls
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what if i'd like to add the activity feed to this restriction?
should i add
|| 'activity'()