Adds one or more members to a specified group.


void addMembersToGroup (mixed $members, int $group[, string $type[, bool $permissionCheckDone]])

Parameter $members

Expected type: Mixed
Description: The ID(s) of one or more members to add to this group

Allowed types for $members
Allowed values Description
Integer The ID of a single member (can also be a string)
Array of Integers An array containing the IDs of one or more members

Parameter $group

Expected type: Integer
Description: The ID of the group to add the member(s) to. Can't be -1 (Unregistered Guests), 0 (Regular Members), 3 (Moderator), or the ID of any post-based group

Parameter $type

Expected type: Enumerated String
Description: What type of assignment this should be

Possible string values
Allowed values Description
'auto' SMF will add it as a primary group if the member doesn't have a primary group. Otherwise it will be added as an additional group. Default value.
'force_primary' SMF will make this their primary group regardless of whether or not they're already in a primary group (existing primary group will not be reassigned as an additional group...)
'only_additional' SMF will only add it as an additional group.
'only_primary' SMF will add it as a primary group, but only if the member doesn't have a primary group (otherwise they won't get added to the group)

Parameter $permissionCheckDone

Expected type: Boolean
Description: Whether or not a check has been done to see if the current user has permission to manage membergroups. Defaults to false.


  • Requires the manage_membergroups permission.
  • Returns true on success or false on failure.
  • The type parameter specifies whether the group is added as primary or as additional group.
  • Function has protection against adding members to implicit groups (ie Unregistered Guests, Moderator or a post group)
  • Non-admins are not able to add members to the admin group.
View all versions of this function