Hide everything from BuddyPress to non-logged in users
-
Hello !
First of all, I apologize if the answer already exists, but I am new to the php language, and I do not understand much …
I created a website for an organization, and I set up a community space thanks to Buddy Press and Youzify.
Here is my question: I want to make this space completely closed, and not accessible to non-logged in users. I tried putting this php code in wp-content / plugins / bp-custom.php:
<? php
/ **
* Redirect the Buddypress directories to the 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 pages Buddypress;
$ bp_pages = get_option (‘bp-pages’);// Get the redirection URL
$ redirect_url = youzify_get_login_page_url ();wp_redirect ($ redirect_url);
go out();
}
}add_action (‘template_redirect’, ‘yzc_redirect_bp_directories_to_login_page’);
Now unconnected users cannot have access to member directory and groups directory, but I would like to block access to all BuddyPress pages (such as member profile pages, activity page. ..) and redirect to the login page.
Could someone help me complete this piece of code?
Thank you for your help
- You must be logged in to reply to this topic.