Introduction
By default, BuddyBoss does not provide an option to restrict logged-in users from accessing the home page. You can achieve this by adding a small function to your child theme, which redirects logged-in users to another page of your choice. This guide explains how you can restrict logged-in users from accessing the home page.
Custom Workaround
Before proceeding, make sure you have a complete site backup.
- In your WordPress admin dashboard, go to Appearance > Theme File Editor.
- Under Select theme to edit, choose your active theme (preferably BuddyBoss Child Theme), then click Select.
- From the Theme Files list, click Theme Functions (functions.php).
- Paste the following code just before the closing PHP tag (?>):
function redirect_logged_in_user_to_profile() {
// Check if the user is logged in and trying to access the home page
if ( is_user_logged_in() && is_front_page() ) {
// Redirect to the page (replace 'profile' with the actual slug of your target page)
wp_redirect( site_url('/profile') );
exit;
}
}add_action( ‘template_redirect’, ‘redirect_logged_in_user_to_profile’ );
- Click Update File to save your changes.
Troubleshooting and FAQs
Q: Logged-in users are not being redirected, what should I check?
A: Ensure the code is added to the active child theme’s functions.php and clear any caching plugins.
Q: Can I redirect users to a different page?
A: Yes, replace ‘profile’ with the slug of any page you want users to be redirected to.
Q: Will this affect visitors who are not logged in?
A: No, only logged-in users are redirected.
Q: Can I revert this change easily?
A: Yes, remove the code from functions.php and save.
Q: Who can I contact for further assistance?
A: Check the BuddyBoss Support Policy or consult a developer.