[Resolved] Hide user profile fields & custom tabs from non-logged in users
-
Can anymore provide some guidance on hiding BuddyPress user profile fields and custom tabs from non-logged in users?
I’ve been trying to figure out how to prevent non-logged in users from viewing my BuddyPress pages, but I can’t seem to quite make everything work. So far, I’ve been able to figure out how to restrict access to the Members page and redirect non-logged in users to the login page. I put the following code in my bp-custom.php file, which is in my plugins folder. I got the code from this BuddyPress forum page (https://buddypress.org/support/topic/hiding-groups-activity-members-list-to-non-members/).
<?php /** * Change BuddyPress default Members landing tab. */ define('BP_DEFAULT_COMPONENT', 'profile' ); /* Prevent logged out users from accessing bp activity page */ function nonreg_visitor_redirect() { global $bp; if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_group_forum() || bp_is_page( BP_MEMBERS_SLUG ) ) { if(!is_user_logged_in()) { //just a visitor and not logged in wp_redirect( get_option('siteurl') . '/wp-login.php' ); } } } add_filter('get_header','nonreg_visitor_redirect',1); ?>
However, non-logged in users can still view each user’s page and their profile tabs. How can I restrict access to those pages as well? I’d rather not use another plugin.
- The topic ‘[Resolved] Hide user profile fields & custom tabs from non-logged in users’ is closed to new replies.