We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 813 ☆ A M B ☆
    • 326 Posts
    If I was better at working with APIs, I’m pretty sure this would be an easy one to figure out.

    I’m using FileUpload, which already allows you to restrict its use to specific Web User Groups using the &uploadgroups parameter (in fact, it won’t even show up on the page if you’re not part of the correct Web Group). This is perfect, except I need it to be based on Manager Groups, not Web User Groups.

    In the snippet, the line that determines the Web Group looks like this:

    $output = '';
    $canupload = $uploadgroups=='' || $modx->isMemberOfWebGroup(explode(",", $uploadgroups));


    I was hoping there would be a call in the API to simply change "isMemberOfWebGroup" to something like "isMemberOfManagerGroup", but I think it’s more complex than that. Or maybe it isn’t, but this is where my ability to work with the API really falls short. This link is about as close as I’ve gotten to a solution, but I’m not sure how to implement it:

    http://wiki.modxcms.com/index.php/API:getUserDocGroups

    Any suggestions? I could really use some help from people with a thorough understanding of the API.

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It doesn’t look as though that will get the manager user’s doc groups; it checks for whether or not you’re in the front-end (web page) or back-end (manager) and presumes that if you are in the front-end you’re only interested in web user groups.

      I suspect that you’ll have to check the $_SESSION yourself; $_SESSION[’mgrDocgroups’]
      [mgrDocgroups] => Array
      (
      [ 0 ] => 2
      [ 1 ] => 1
      )

        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
        • 813 ☆ A M B ☆
        • 326 Posts
        Thanks for the help! Unfortunately, my skill level is just a little bit short of being able to put what you said into practice. I tried, and it broke things smiley

        If you don’t mind and when you have a moment, can you show me the exact syntax of what you’re suggesting below? I don’t know how to insert it into the snippet without it blowing everything up.