We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17667
    • 108 Posts
    I am working on a plug-in and need to add a user group to to a form customization profile through the API. It seems like there should be a way but I cannot find any documentation.

    I have the user group ID and form customization profile ID. I am guessing it may start with something like this:
    $formProfileAccess = $modx->newObject('modFormCustomizationProfile');


    Any help would be greatly appreciated.
      • 17667
      • 108 Posts
      I have this code for attaching a resource group to a user group. It seems like I should be able to take the principals of this and apply it to adding a user group to a form customization profile. I've tried some variations but no luck so far.
                  $resourceGroupAccess = $modx->newObject('modAccessResourceGroup');
                  $resourceGroupAccess->set('target', $resourceGroup->get('id'));
                  $resourceGroupAccess->set('principal_class', 'modUserGroup');
                  $resourceGroupAccess->set('principal', $userGroup->get('id'));
                  $resourceGroupAccess->set('authority', $resourceGroupAuthority);
                  $resourceGroupAccess->set('policy', $resourceGroupPolicy ); // 
                  $resourceGroupAccess->set('context_key', 'mgr');
                  $resourceGroupAccess->save();