Inherit parent resource group.
/*
Inherit resource groups only if resource is new
Source: http://forums.modx.com/thread/79531/inheriting-resource-groups
Author: paulmerchant (http://forums.modx.com/u/paulmerchant)
Compatible 2.2.x
Not tested with 2.3.x (might even not be necessary anymore in 2.3.x ...)
*/
if ($mode == modSystemEvent::MODE_NEW) {
/* get the id of the parent */
$parentId = $_POST['parent'];
/* get all the resource group data of the parent as a collection */
$groupCollection = $modx->getCollection('modResourceGroupResource', array('document'=>$parentId));
/* join the resource to resource groups in the collection */
foreach($groupCollection as $group) {
$success = $resource->joinGroup($group->get('document_group'));
}
}