zoadie Reply #1, 3 months, 2 weeks ago
Hi!
I'm trying to automatically create a "ResourceGroup", a "Resource" and an "UserGroup" for each new registered user.
I created the following plugins onUserSave:
My questions are:
1. How can I assign User-X to UserGroup-X
2. How can I assign Resource-X to ResourceGroup-X
3. Is there a way to have all this code in only one plugin. I tried but it doesn't work.
I'm quite familiar with the Modx basics but I want to learn more about the advanced features and Developing with Modx and your help will be greatly appreciated.
ps: I'm using Revo 2.2-pl2
I'm trying to automatically create a "ResourceGroup", a "Resource" and an "UserGroup" for each new registered user.
I created the following plugins onUserSave:
<?php
//create a unique ResourceGroup for each user
$ID = $user->get('id');
$response = $modx->runProcessor('security/resourcegroup/create',array('name' => 'ResourceGroup-'.$ID));
if ($response->isError()) {
return $response->getMessage();
}
$resourceGroupArray = $response->getObject();
return 'The Resource Group "'.$resourceGroupArray['name'].' was created with ID '.$resourceGroupArray['id'];
<?php
//create a Resource for each new user
$ID = $user->get('id');
$response = $modx->runProcessor('resource/create',array('pagetitle' => 'Resource-'.$ID, 'published' => 1));
if ($response->isError()) {
return $response->getMessage();
}
$resourceArray = $response->getObject();
return 'The Resource"'.$resourceArray['name'].' was created with ID '.$resourceArray['id'];
<?php
//create a userGroup for each new user
$ID = $user->get('id');
$response = $modx->runProcessor('security/group/create',array('name' => 'UserGroup-'.$ID));
if ($response->isError()) {
return $response->getMessage();
}
$userGroupArray = $response->getObject();
return 'The User Group "'.$userGroupArray['name'].' was created with ID '.$userGroupArray['id'];
My questions are:
1. How can I assign User-X to UserGroup-X
2. How can I assign Resource-X to ResourceGroup-X
3. Is there a way to have all this code in only one plugin. I tried but it doesn't work.
I'm quite familiar with the Modx basics but I want to learn more about the advanced features and Developing with Modx and your help will be greatly appreciated.
ps: I'm using Revo 2.2-pl2
)