<![CDATA[ Retrieving Settings from User Group - MODX Community Forums]]> https://forums.modx.com/thread/?thread=103876 <![CDATA[Retrieving Settings from User Group]]> https://forums.modx.com/thread/103876/retrieving-settings-from-user-group#dis-post-558643 I'm having trouble trying to find out how to get the values from a User's Group.

Basically, I'd like to be able to get a custom API key that is stored with the User's Group. This is the beginning of creating an admin interface to be able to send push notifications for clients.

For example: (2 groups)

Group: Steve's Cars
Users: Steve, Andrew
OneSignalAPIkey: 123456789
GoogleAPIKey: AAAAAA123


Group: John's Phones
Users: John
OneSignalAPIkey: 111111129
GoogleAPIKey: BBBBBB123



I looked at the getOption() examples and Mark's ClientConfig, but maybe I'm doing it wrong or I'm using the wrong tools.

I'd like to be able to set up a call, where my code can just go and get the correct value OneSignalAPIkey, when a user asks for it.

If client "Steve" needs to send a push notication, then modx would need get the correct OneSignalAPIkey value stored in the relevant group settings.

I have a snippet (originally copied from the internet) like this, which is returning "No Key"

$key = $modx->getOption('OneSignalAPIkey', $scriptProperties, '', true);
if (!empty($key)) {
    $setting = $modx->getObject('modUserSetting', array('key' => $key), false);
    if ($setting) {
        $output = $setting->get('value');
    } else {
        $output = 'Could not get setting object';
    }
} else {
    $output = 'No Key';
}
echo $key;
echo $output;


Thanks.]]>
vr_driver May 19, 2018, 05:21 AM https://forums.modx.com/thread/103876/retrieving-settings-from-user-group#dis-post-558643
<![CDATA[Re: Retrieving Settings from User Group]]> https://forums.modx.com/thread/103876/retrieving-settings-from-user-group#dis-post-558649 It sounds like the setting is a group setting, not a user setting. If so, try this:

$setting = $modx->getObject('modUserGroupSetting', array('key' => $key), false);


If there is more than one user group with that key, you'll also need to specify the user group ID in your criteria array.

]]>
BobRay May 19, 2018, 08:35 PM https://forums.modx.com/thread/103876/retrieving-settings-from-user-group#dis-post-558649
<![CDATA[Re: Retrieving Settings from User Group]]> https://forums.modx.com/thread/103876/retrieving-settings-from-user-group#dis-post-558645 Sorry for wasting your time.
]]>
vr_driver May 19, 2018, 05:55 AM https://forums.modx.com/thread/103876/retrieving-settings-from-user-group#dis-post-558645