<?php $parent = $resource->get('parent'); if($parent == 1170 && $mode == 'new'){ //set variables $page_id = $resource->get('id'); $page_title = $resource->get('pagetitle'); //create new resource group $newResourceGroup = $modx->newObject('modResourceGroup',array('name'=>$page_title,'private_memgroup'=>0,'private_webgroup'=>0)); if(!$newResourceGroup->save()){ return "Unable to save the Resource Group. The Group may already exist."; } //add current resource to new resource group $newResourceGroupId = $newResourceGroup->get('id'); $resource->joinGroup($newResourceGroupId); if(!$resource->save()){ return "Unable to add to the User Group."; } //create new usergroup $newUserGroup = $modx->newObject('modUserGroup',array('name' => $page_title)); if($newUserGroup->save()){ $modx->log(MODX_LOG_LEVEL_ERROR, 'User group created.' ); return true; }else{ return "Unable to save the User Group. The Group may already exist."; } }else{ return true; }
This question has been answered by BobRay. See the first response.
target (string) - ID of resource group principal_class (string) - 'modUserGroup' principal (integer) - ID of User Group authority (integer) - 9999 policy (integer) - ID of policy context_key (string) - 'web' // context of resources