We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10194
    • 16 Posts
    Hi, I’m currently running Evo. 1.0.5 and I wanted to create a module similar to the following:

    http://www.kunane.com/modx/managing-resources-via-module.html

    But with a check on the usergroup to display the appropriate link.

    Unfortunately I’m getting an error:

    Fatal error: Call to a member function isMember() on a non-object in C:\wamp\www\Projects\Websites\brucecounty.on.ca\brucecounty_ver_2\brucecountyonca\manager\processors\execute_module.processor.php(120) : eval()’d code on line 3

    What am I doing wrong?

    Here is the code:

    global $modx;
    
    if($modx->user->isMember('Human Resources'))
    {
        $news_id = 126; //ID of your container
    }
    elseif($modx->user->isMember('Planning'))
    {
        $news_id = 126; //ID of your container
    }
    else
    {
        $news_id = 123; //ID of your container
    }
    
    setcookie('webfxtab_childPane', 1, time()+3600, '/');
    $modx->sendRedirect("index.php?a=3&id=$news_id",0,"REDIRECT_HEADER");


    I’m running the following:
    Windows 7
    PHP Ver 5.2.4
    MySQL 5.0.45
    Firefox 3.6.12

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That looks more like a Revo function to me. Evo has isMemberOfWebGroup() which takes an array of web group names as a parameter.

      http://wiki.modxcms.com/index.php/API:isMemberOfWebGroup
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 10194
        • 16 Posts
        Thanks Susan, I’ll take a look at this and get back to you.
          • 10194
          • 16 Posts
          I tried that function, but is that not for Web Users? I’m looking for something to check for user groups on Manager Users, is this the function I need?

          http://wiki.modxcms.com/index.php/API:getUserDocGroups
            • 10194
            • 16 Posts
            I got this to work for me:

            $documentGroups = $modx->getUserDocGroups(true);
            
            if (in_array("Human Resource Pages", $documentGroups)) 
            {
                $news_id = 126;    
            }
            elseif(in_array("Planning Pages", $documentGroups)) 
            {
                $news_id = 127;
            }
            else
            {
                $news_id = 0;
            }
            
            setcookie('webfxtab_childPane', 1, time()+3600, '/');
            $modx->sendRedirect("index.php?a=3&id=$news_id",0,"REDIRECT_HEADER");


            Thanks for the help Susan!

            - Brad