1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Auto Follow One User on Member Registration

How to Auto Follow One User on Member Registration

Introduction

BuddyBoss does not automatically make new members follow a specific user. You can set up an auto-follow for one user by adding a small custom function to your active theme. This ensures that every newly registered member automatically follows the user you specify. This guide explains how to auto follow one user on member registration.

Custom Workaround

Before proceeding, make sure you have a complete site backup.

  1. Navigate to Appearance > Theme Editor in your WordPress admin dashboard.
  2. Under Select theme to edit, choose your active theme (preferably BuddyBoss Child Theme), then click Select
  3. From the Theme Files list, open Theme Functions (functions.php)
  4. Add the following code just before the closing PHP tag (?>):

/* Auto follow a specific user */

function lauralisa_followjlearn( $user_id ) {

    if( !$user_id ) return false;

    $jlearn = 80; // Replace 80 with the user ID you want new members to follow

    bp_start_following( array(

        ‘leader_id’   => $jlearn,

        ‘follower_id’ => $user_id

    ) );

}

add_action( ‘bp_core_activated_user’, ‘lauralisa_followjlearn’ );

Notes
$user_id is the ID of the newly registered user

$jlearn is the ID of the user that new members will automatically follow

bp_start_following initiates the following relationship between the new member and the specified user

  1. Click Update File to save the 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: The new members are not auto-following the user
A: Ensure the user ID in $jlearn exists and the code is correctly added before the closing ?> tag

Q: Can I auto-follow multiple users
A: Yes. You can call bp_start_following multiple times inside the function for each user ID

Q: Will this affect existing members
A: No. This code only runs when a new user completes registration

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.