We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37929
    • 18 Posts
    Hello, i can't find the way of building manager links for users.

    Now i do it this way :
    <a href="/manager/index.php?a=34&id=$myUserId">Manage user $myUserId</a>
    

    it works but it's not nice.
    could someone please help ?
      • 33968
      • 863 Posts
      How would you prefer to do it?
        • 37929
        • 18 Posts
        i mean in php something like this :
        $myUser = 2 ;
        $output = $modx->makeUserUrl( $myUser );
        

          • 33968
          • 863 Posts
          Is this for use in a snippet or is it part of a larger, class based component you are building?
            • 37929
            • 18 Posts
            it's for a snippet that lists users in the manager and i would like when clickng on the username is goes straight on the "update user" manager page.

            Now it's just a draft but maybe later it ll be part of a class based component.
              • 33968
              • 863 Posts
              To be honest unless you'll be using this function again and again in various places you're just creating more work for yourself. Put it into a local function if you like, but if you're just doing that once I don't see a problem with it.

              You're running the snippet in the manager?
                • 37929
                • 18 Posts
                thanks for your help
                its a "Messages" snippet, users can send, receive, delete, reply messages, etc

                They can warn the site admin for an innapropriate message they got from another user.
                When this happens, the site admin receives a copy of the inapropriate message in his manager inbox.

                In this message I think it could be a good thing to have link leading right to the user's profile.

                And because I would like to make a package and share this snippet later, i would like to have a portable code. That's not the case with an hard link ( url params are not the same on others modx install )

                No, i do not run the snippet in the manager, i only want to display links in these message to the admin.
                  • 33968
                  • 863 Posts
                  You can get the action id like this which would be a good way to make it portable:
                  $action = 'security/user/update';
                  
                  $actionObject = $modx->getObject('modAction',array(
                      'namespace' => 'core',
                      'controller' => $action,
                  ));
                  
                  if (!empty($actionObject)) {
                      $actionId = $actionObject->get('id');
                  }
                  

                  You could build that right into your makeUserUrl function smiley
                    • 37929
                    • 18 Posts
                    thank you very much !