I am using the Drupal 7 version of the Group module. I found this Drupal 8 code which adds a user to a group, and I can't find anything similar for Drupal 7.
use Drupal\Core\Entity\ContentEntityBase;
$account = \Drupal\user\Entity\User::load('uid');
$group = \Drupal\group\Entity\Group::load($group_id);
$group->addMember($account);
$group->save();
What is the equivalent Drupal 7 code?
I tried using the following code, but it throws an error.
<?php
$account = user_load($uid);
$group = entity_load_single('group', 1);
$group->addMember($account);
$group->save();
?>
The error is the following one.
Object of class stdClass could not be converted to int in Group->addMember()