We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I looked at the set() code for modUser. The sudo field can't be set directly - you have to use the setSudo() method. See if this works:

    /* sudo prevention code - only admins can set the sudo field */'
          if (! $modx->user->isMember('Administrator')) {
              $user->setSudo(false);
              $user->save();
          }
    return;
    [ed. note: BobRay last edited this post 9 years, 9 months ago.]
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 52804
      • 36 Posts
      It works! - thanks a lot Bob...
        • 3749
        • 24,544 Posts
        I'm glad I could help. Thanks for reporting back.

        You may still have an issue if the users can modify the user's user groups and authority.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 52804
          • 36 Posts
          Quote from: BobRay at Dec 12, 2016, 12:52 AM
          I'm glad I could help. Thanks for reporting back.

          You may still have an issue if the users can modify the user's user groups and authority.

          Thanks Bob, I've just discovered that this script causes a conflict with the [[!Register]] snippet. You can only register if logged in to the manager as administrator, otherwise it just hangs and crashes. Presumably because [[!Register]] also uses the OnUserSave Event? - I've had to disable it for now..
            • 3749
            • 24,544 Posts
            You can determine the order in which the plugins execute by setting their priority fields. That might help.

            What's the nature of the conflict?

            You could also try connecting it to OnUserBeforeSave.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 52804
              • 36 Posts
              When the sudo plugin is enabled, if you submit a registration form the script just hangs for about 5-10 seconds and ends in a 404 error (or 500 error if allocated memory in php.ini is less than about 300M). The user gets added but no activation email is sent. Disable the sudo plugin and all works fine.

              I hadn't thought about experimenting with priorities and other system events but will try that and report back. Thanks again for your help and advice smiley