I’m trying to create hierarchical user groups via xPDO, but when I set the "parent" attribute, it doesn’t seem to stick... when I view the user groups via "Security --> Access Controls", the user group is never created as a child of the user group I’m trying to make it a child of.
Here’s the code snippet:
$UG = $modx->newObject('modUserGroup');
$datestamp = date("Y-m-d H:i:s");
$UG->set('name', $new_name );
$UG->set('description', 'Automatically created '.$datestamp);
$UG->set('parent', 8 ); // hard-coded: all new user groups are children of the "Clients (8)"
$UG->save();
Curiously, I’ve noticed that some of the user groups I’ve deleted via the MODx manager are still present in the database:
select * from modx_membergroup_names;
What gives? Can I not hard-code the parent like that?