We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3349
    • 126 Posts
    Hello

    Hope you can help me...

    I currently have a group of 72 Web Users. I have assigned them into 18 groups of 4 using a customField "group" (i.e each person has been assigned a group number 1, 2, 3, 4...18)

    I have a snippet call: [!WebLoginPE? &type=`users` &usersTpl=`usersGroupTpl` &usersList=`Groups:default:default:fullname:ASC:group(1)`!]

    As you would expect, this returns a list of the four users in group 1

    What I want to do is dynamically return the list of users that belong to the same group as the user viewing that list. (i.e if Bob was in group 11 he would see a list of the other users in his group)

    I tried the obvious:

    [!WebLoginPE? &type=`users` &usersTpl=`usersGroupTpl` &usersList=`Groups:default:default:fullname:ASC:group([+view.group+])`!]

    But I dont think it accepts this syntax. Can anyone shed any light as to how I can pull through the group number of the current user?

    Thanks

    bS
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That might work if you have the PHx plugin installed.

      I would use a snippet to fetch the user’s group from the SESSION.
        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
        • 3349
        • 126 Posts
        Thanks for replying Susan

        I already have the PHx plugin installed before I tried this...

        I would use a snippet to fetch the user’s group from the SESSION.

        Im not too sure about how I would do this, could you help me out in anyway?

        Thanks

        bS
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Create a snippet that gets the user’s group ID from the SESSION, then make a query to the database to fetch and return all the other users belonging to that group.
            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
            • 3349
            • 126 Posts
            Hi Susan

            Thanks again

            I created a snippet "getGroup" that got the userID of the SESSION and retrieved the group number.

            I then called that snippet in the original WebLoginPE snippet call (as below) and it worked...

            [!WebLoginPE? &type=`users` &usersTpl=`usersGroupTpl` &usersList=`Groups:default:default:fullname:ASC:group([!getGroup!])`!]


            Im not sure why the snippet call accepted the snippet call but not the webloginpe placeholder?

            Cheers
              • 36533
              • 65 Posts
              bigSlim,

              Would you mind sharing your snippet to retrieve the group from the session? I'm doing almost the exact same thing with groups and working off your example.

              Thanks!