We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40041
    • 36 Posts
    Can someone give me some direction on how to get/check the value of the "Class Key" field of the logged in user?

    I need a way to read this and do things based on the value. Regular Modx users contain "modUser" - Hybridauth users are "haUser" for example.

    Any help would be appreciated. I can't seem to get the contents of this field!

    This question has been answered by Everettg_99. See the first response.

    [ed. note: robcarey last edited this post 13 years, 1 month ago.]
    • discuss.answer
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      You should be able to read this attribute just like any other using the "get" method:

      $user = $modx->getUser();
      $class_key = $user->get('class_key');
      // or...
      $class_key = $modx->user->get('class_key');
      // or... in general for any user, e.g. user 123
      $user = $modx->getObject('modUser', 123);
      $class_key = $user->get('class_key');
      


      Is that working for you?

      If the haUser class was loaded at runtime, then the rest of the behavior would be dictated by that extension, so it's possible some behaviors have been overridden. [ed. note: Everettg_99 last edited this post 13 years, 1 month ago.]
        • 3749
        • 24,544 Posts
        There's a handy reference here to all the field names available with get():

        http://bobsguides.com/modx-object-quick-reference.html#modUser
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 40041
          • 36 Posts
          Thanks all for the tips - it's working. I think I've been building this site for too long. I swear I had tried those suggestions previously and it didn't work... I think my brain is failing me smiley