Basically, you need to write the logic to determine which group to add them too. Here's the PHP you'll need (
NOT TESTED):
PHP:
class Xarcell_DataWriter_User extends XFCP_Xarcell_DataWriter_User
{
protected function _preSave()
{
parent::_preSave();
if ($this->get('dob_day') && $this->get('dob_month') && $this->get('dob_year'))
{
// Get age
$age = $this->getModelFromCache('XenForo_Model_UserProfile')->calculateAge(
$this->get('dob_year'), $this->get('dob_month'), $this->get('dob_day')
);
// Get mapped usergroup
$newUsergroup = $this->_getUsergroupByAge($age);
// Get existing secondary usergroups as an array
$secondaryUsergroupsString = $this->get('secondary_group_ids');
$secondaryUsergroups = explode(',', $secondaryUsergroupsString);
foreach($newUsergroup AS $id)
{
// if its not in the array...
if(!in_array($id, $secondaryUsergroups))
{
// add it.
$secondaryUsergroups[] = $id;
}
}
// Set the new list of secondary usergroups
$this->setSecondaryGroups($secondaryUsergroups);
}
}
protected function _getUsergroupByAge($age)
{
$newGroups = array();
if($age > 5 && $age < 10)
{
// Set the number here to be an ID of the 6-9 group
$newGroups[] = 4;
}
if($age >= 10 && $age <= 20)
{
// Set the number here to be an ID of the 10-20 group
}
return $newGroups;
}
}
Now, you'll have to modify _getUsergroupByAge() and add more if() statements. >= and <= mean greater than OR equal too / less than OR equal too so, you'll use this if you want them to be included in the range. The first one exludes them. You'll need the group IDs from the ACP where it says $newGroups[] = X;.