SyncGenerator::addUserToBpGroup( $userId,  $type,  $remove )

Add a user to bp group by role

Description

Source

File: bp-integrations/learndash/library/SyncGenerator.php

674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
protected function addUserToBpGroup($userId, $type, $remove)
{
    $groupMember = new BP_Groups_Member($userId, $this->bpGroupId);
    $syncTo = $this->getLdSyncToRole($type);
 
    if ($remove) {
        return $groupMember->remove();
    }
 
    $groupMember->group_id     = $this->bpGroupId;
    $groupMember->user_id      = $userId;
    $groupMember->is_admin     = 0;
    $groupMember->is_mod       = 0;
    $groupMember->is_confirmed = 1;
 
    if ('user' != $syncTo) {
        $var = "is_{$syncTo}";
        $groupMember->$var = 1;
    }
 
    $groupMember->save();
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.