1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Redirect Users to Login After Registration

How to Redirect Users to Login After Registration

Introduction

BuddyBoss shows a “Successfully Registered” page after account creation. There is no built-in option to bypass this page and redirect users directly to the login page. You can achieve this by adding a custom function to your theme. This guide explains how you can redirect users to login after registration.

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 (?>):
remove_action( 'bp_actions', 'bp_members_action_activate_account_custom' );

function bp_members_action_activate_account_custom() {

    if ( ! bp_is_current_component( 'activate' ) ) {

        return;

    }

    if ( is_user_logged_in() ) {

        return;

    }

    if ( ! empty( $_POST['key'] ) ) {

        $key = wp_unslash( $_POST['key'] );

    } elseif ( ! empty( $_GET['key'] ) ) {

        $key = wp_unslash( $_GET['key'] );

    }

    if ( empty( $key ) ) {

        return;

    }

    $bp   = buddypress();

    $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );

    // If there were errors, add a message and redirect

    if ( ! empty( $user->errors ) ) {

        bp_core_add_message( $user->get_error_message(), 'error' );

        bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );

    }

    bp_core_add_message( __( 'Your account is now active!', 'buddyboss' ) );

    // Redirect users to the login page instead of the confirmation page

    bp_core_redirect( 'http://buddyboss.local/login/' );

}

add_action( 'bp_actions', 'bp_members_action_activate_account_custom' );

Note: The line bp_core_redirect( ‘http://buddyboss.local/login/’ ); controls the redirect to the login page. Replace the URL with your actual login page URL if different.

  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: Users are still seeing the “Successfully Registered” page, what should I check?
A: Ensure the code is added to the active child theme’s functions.php and that you cleared any caching plugins.

Q: Can I redirect users to a different page?
A: Yes, replace ‘http://buddyboss.local/login/’ with the URL of the desired page.

Q: Will this affect account activation errors?
A: No, users with activation errors are still redirected to the activation page with an error message.

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: Please review 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.