/*Reverse sticky header*/
  1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. Redirect Login To The Referring Page Rather Than A Specific Page

Redirect Login To The Referring Page Rather Than A Specific Page

Please be advised that there’s currently no out-of-the-box option to do this in BuddyBoss. Modifications are typically considered custom work, but we are making an exception in this case. Kindly check our Support Policy here: https://www.buddyboss.com/support-policy/.

To ensure that users are redirected back to the referring page after logging in, you can use the login_redirect filter to handle the redirection. Kindly try adding the following code in your theme files:

1. Go to Appearance > Theme File Editor

2. Under “Select theme to edit”, choose (BuddyBoss Child/Whatever theme is active), then click “Select”.

3. Below Theme Files, select Theme Functions (functions.php).

4. Append the following just before the closing PHP tag “?>”:

function custom_login_redirect($redirect_to, $request, $user) { // Define your custom URL $custom_url = 'https://yourcustomurl.com/custom-page'; // Check if there is a referer URL if (!empty($_SERVER['HTTP_REFERER'])) { return $_SERVER['HTTP_REFERER']; } // Use custom URL if no referer is available return $custom_url; } add_filter('login_redirect', 'custom_login_redirect', 10, 3);

NOTE: Please make a backup of your site.

Replace ‘https://yourcustomurl.com/custom-page‘ with the URL you want to redirect users to by default. You need to add page link on $custom_url = 

5. Click “Update File”.

Note: Any modifications are considered as custom work already. Know more about our Support Policy here: https://www.buddyboss.com/support-policy/

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support

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

"*" indicates required fields

Get Started

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

Name*