We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10152
    • 156 Posts
    Hi, I apologize for posting so many questions.

    I’ve spent hours of searching and can’t find how to retrieve user member group id or user member group name.
    I just found modUser::isMember that should check if a members belongs to some groups, but can’t guess what’s the problem when using it in a snippet :
    <?php
    $modx->$user->isMember('announcers');
    ?>
    

    Fatal error: Cannot access empty property in /var/www/core/model/modx/modscript.class.php(89) : eval()'d code on line 6
    


    What did I miss ? grin
      • 28215
      • 4,149 Posts
      Quote from: French at Feb 25, 2010, 07:43 AM

      <?php
      $modx->$user->isMember('announcers');
      ?>
      

      Fatal error: Cannot access empty property in /var/www/core/model/modx/modscript.class.php(89) : eval()'d code on line 6
      

      What did I miss ? grin

      It should be:

      $modx->user->isMember('announcers');
      


      No $ on user.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 10152
        • 156 Posts
        Thanks.
          • 28000 ☆ A M B ☆
          • 397 Posts
          How do you find out if another user (not the current user) belongs to a certain group?

          I want to find out if the last editor of a resource belongs to a certain group.
          My code so far gives me a syntax error.

          $usergroup='Editor';
          $id = $modx->resource->get('id');
          $resource = $modx->getObject('modResource', $id );
          
          $editor = $resource->get('editedby');
          
          $user=$modx->getObject('modUser',array('id'=>$editor));
          
          $checkMembership = $modx->$user->isMember($usergroup);
          
          return $checkMembership;
          
            Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
            • 28000 ☆ A M B ☆
            • 397 Posts
            I may have just answered my own question... in line 9 I deleted the reference to modx and it seems to work

            $checkMembership = $user->isMember($usergroup);
              Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.