We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Got an odd one now, I have a client migrating from Drupal to Modx, they want their users all to agree [again] to the website terms of service upon their first login to the new site.
    Now I’ve seen a bit about the various triggers being able to call different snippets at certain times, does this sound like something that can be done with a trigger? i.e. user logs in, if database field ’terms’ is ’not agree’ send them to the terms form?

    -thanks
    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 26016
      • 561 Posts
      There are a whole bunch of Events you can watch for. For instance, you could write a plugin, which is set to fire on...
      OnManagerAuthentication


      Here’s a list of Events.
      http://wiki.modxcms.com/index.php/System_Events

      I think this is pre-Revo, but they should be mostly the same. You can edit an existing plugin, and look for the System Events tab to see a current list.

      The only problem is, how do you "know" that the person has looked at it or not. Maybe by setting a cookie? Above my paygrade. Hope that gives you some things to look at.
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 3749
        • 24,544 Posts
        You could mark them all as inactive and set the active field when they log in.

        Which version of MODX?
          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
          • 26503
          • 620 Posts
          Hi Bob;

          it Revo, most recent....

          I’m thinking maybe just a snippet on the login submit event [whatever that might be - haven’t looked yet] that checks that field in the database and refers them to a different page then specified in the !login parameters if they haven’t agreed [i.e. I default all the imported users to selection to null]
          I suppose then I could auto log them out if they choose ’wrong’

          -sean
            *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

            Sean Kimball CLP, CLS.
            Technical Director / Sr. Developer | BigBlock Studios
            ._______________________________________________.
            Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
            27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
            phone/fax: 905-426-5525
            • 3749
            • 24,544 Posts
            I think OnManagerLogin would do. It fires after the user has been authenticated and cleared for Manager access.

            This should set all users to inactive:

            $usersObjs = $modx->getCollection('modUser');
            
            foreach($userObjs as $userObj) {
            
                $userObj->set('active','0');
                $userObj->save();
            
            }


            You might be able to just add the TOS to the login form with a snippet that returned the TOS for inactive users and an empty string for active users. Then you’d just need a plugin that set the active field on a successful login.

            If the client thinks it’s necessary, you could put a checkbox in the TOS and check it in the plugin, redirecting users somewhere with $modx->sendRedirect() if the user is inactive and the checkbox is not checked.
              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
              • 26503
              • 620 Posts
              Hi Bob;

              thanks, actually they are all web users - none will have access to the manager, so shouldn’t I be using the onWebLogin event?

              -thanks
              -sean
                *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                Sean Kimball CLP, CLS.
                Technical Director / Sr. Developer | BigBlock Studios
                ._______________________________________________.
                Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                phone/fax: 905-426-5525
                • 26503
                • 620 Posts
                Actually scratch that - I want the event ’onWebAuthentication’ -- i.e. if they don’t agree to the terms, I don;t want them poking around in the restricted areas.

                hmm this just got more complicated, now I have to figure out how to capture the terms of service selection, record it, THEN somehow pass their credentials on for authentication.

                Or does it work like this: when the onWebAuthentication event fires, the user is actually already authenticated, there is just no session started, i.e. all I actually have to do is deal with the TOS selection then just pas a ’true’ or ’false’ as the return value to the plugin?

                -sean
                  *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                  Sean Kimball CLP, CLS.
                  Technical Director / Sr. Developer | BigBlock Studios
                  ._______________________________________________.
                  Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                  27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                  phone/fax: 905-426-5525
                  • 3749
                  • 24,544 Posts
                  OnWebAuthentication should be it. The user has been authenticated and determined to be a front-end user, but hasn’t been forwarded anywhere. If your plugin returns true, the normal login sequence will continue.
                    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