1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Restrict Logged-in Users From Accessing the Home Page

How to Restrict Logged-in Users From Accessing the Home Page

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.

  1. In your WordPress admin dashboard, go to Appearance > Theme File Editor.
  2. Under Select theme to edit, choose your active theme (preferably BuddyBoss Child Theme), then click Select.
  3. From the Theme Files list, click Theme Functions (functions.php).
  4. 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’ );

  1. Click Update File to save your changes.

Note: Modifications are typically considered custom work, but we are making an exception in this case. Please review the BuddyBoss Support Policy.

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.

Was this article helpful?

Related Articles

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

To speak to our Agency consultant, fill in the form found at our Contact Page.

  • Get Started

    Enter your name and email address to get started with your project...

  • This field is for validation purposes and should be left unchanged.