Tagged: access restriction
how can i restrict access to the member directories?
Currently, the directories are not pages so I am having trouble restricting the URL link to the directories that I created.
I’d like to restrict access to the member type directory URLs to only logged in users or a certain user level.
Thanks
Hi David,
Welcome to BuddyDev.You may use the following code to redirect non logged users
add_action( 'bp_template_redirect', function () { if ( ! is_user_logged_in() && bp_is_members_directory() ) { bp_core_redirect( site_url( '/' ) ); } } );
If you are using the Member Types feature of BuddyPress and want to do it for the directory of a specific member type, you may use ‘bp_get_current_member_type()’ to check for that.
Hope that helps.
Regards
BrajeshHello David,
You can use this code in your “bp-custom.php” file. To get more info please refer the following URL:
https://codex.buddypress.org/themes/bp-custom-php/Thank You
Ravi
You must be logged in to reply to this topic.