We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3866 ☆ A M B ☆
    • 350 Posts
    Hi there, I've had loads of help from the Modx team and community members whilst getting to grips with Login and have put together a tutorial which I hope makes sense and will help anyone trying to get to grips with this snippet. I am using all the code included in the tutorial on a live site and all is working fine.

    This is the first time I've put a tutorial together, so please be gentle if I've made silly typos or my code is untidy  ;)

    I've tried to be as logical as possible... and I hope it helps someone else

    UPDATE: New version (Login-A Tutorial v1.1) added as the plugin for EmailOnActivation was firing a 'deactivated message' when users first registered because of course their account is inactive! When we've managed to re-do this plugin to provide for deactivation will add the code.  The code provided for the plugin is only activation.

    UPDATE: 18th Feb 2011 - New version (Login-A Tutorial v1.2) added with new package ActivationEmail added which has superceded the original EmailOnActivation code.

    UPDATE: 21st Feb 2011 - Version 1.2 The code for the Change Password form was incomplete and has now been added.

    UPDATE: 14th Mar 2011 - Version 1.4 - Thanks to the eagle eyes of Odeclas I have made small amendment to Profile code to return [[+mobilephone]] and not [[+cellphone]]

    UPDATE: 29th September 2011 - Version 2 - Updated as now using Revo 2.1.3 and Login 1.7.0. [ed. note: boomerang last edited this post 14 years, 11 months ago.]
      Helen Warner
      Number one pixel!
      Proud to be linked with MODX at Crimson Pixel
      • 24687
      • 14 Posts
      Well done on the tutorial,
      combined with this one
      http://modxcms.com/forums/index.php/topic,57373.msg328398.html

      It’s a perfect building block in creating your own.
      I suspect a lot of people will find these useful

      I haven’t had the time to go threw the hole tutorial yet and test it out but hopefully will later

      Thanks.
        • 3749
        • 24,544 Posts
        Very nice (and thanks for the plug). cool
          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
          • 3866 ☆ A M B ☆
          • 350 Posts
          New version of Login Tutorial added as discovered from client (feeling a little embarressed embarrassed) that the EmailOnActivation plugin was firing a ’your account is deactivated’ on registration because of course the account is inactive! Removed with little piece of code and what is available is for activation.

            Helen Warner
            Number one pixel!
            Proud to be linked with MODX at Crimson Pixel
            • 3749
            • 24,544 Posts
            Quote from: Muggins at Feb 13, 2011, 09:53 AM

            New version of Login Tutorial added as discovered from client (feeling a little embarressed embarrassed) that the EmailOnActivation plugin was firing a ’your account is deactivated’ on registration because of course the account is inactive! Removed with little piece of code and what is available is for activation.

            Are you using the version released through Package Manager? In theory, it will only send the deactivation message when a user’s status *changes* from active to inactive and (again -- in theory) the code only executes when a user is updated, not created.

            The only way I can see it doing that is if the user is saved as active, then saved again as inactive during the registration process.
              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
              • 3866 ☆ A M B ☆
              • 350 Posts
              Just a thought, when a new user registers their details via the registration page an email is fired to this new user to say that they are registered but not active on the system via &activationEmailTpl

              [[!Register? &preHooks=`recaptcha` &submitVar=`registerbtn` &activationEmailTpl=`RegistrationEmail` &activationEmailSubject=`Registration Submitted` &submittedResourceId=`17` &usergroups=`MembersOnly` &postHooks=`hookNotifyAdminEmail`]]

              Could this be what makes the system consider the user active, when in fact in the Manager the user has not yet been activated?

              I have downloaded the latest Login package but I’m using the plugin as was first created - can’t see how to use it as a preHook - advice please wink
                Helen Warner
                Number one pixel!
                Proud to be linked with MODX at Crimson Pixel
                • 3749
                • 24,544 Posts
                First, delete the version I emailed to you and install the ActivationEmail package in Package Manage. I think there may have been a bug in the deactivation section of your version.

                Since it isn’t a snippet, there’s no way to use it as a hook -- but it will still be called whenever a user is saved to the DB, though it ignores users who are being saved for the first time (i.e., created).

                Here’s what it does from the inside. Whenever a user’s active status (or anything else) changes, the user will always be saved to the DB -- otherwise the change wouldn’t be permanent. The ActivationEmail plugin is only called when a user’s record is saved to the DB. The code will execute if and only if an existing user’s record is updated in the DB. If the users status is changing from inactive to active, the users gets one email. If the deactivation option is on, the user will get a different message if their status is changing from active to inactive. If their active status is not changing, the plugin does nothing.


                As you said, the Register snippet sends its own email to the user on registration (and I think another one when they self-activate). If you don’t want users to be able to self-activate, I think you’d just install my package and change the other snippet’s Registration Tpl chunk so it tells the user you’ll be activating them manually and remove the self-activation link/placeholder in that Tpl chunk. ActivationEmail will send them an email when they’re activated manually later.

                Hope that makes sense. wink

                  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
                  • 12352
                  • 101 Posts
                  Hi Muggins,

                  The form of the Change Password resource is not complete in the pdf, is it possible to post the complete resource? Nice work on the tutorial BTW
                    Don't believe anything you read on the net. Except this.
                    • 3866 ☆ A M B ☆
                    • 350 Posts
                    Don’t know how I missed that last little bit on the Change Password form, but it has now been modified and an amended version added.

                    Thanks wink
                      Helen Warner
                      Number one pixel!
                      Proud to be linked with MODX at Crimson Pixel
                      • 12352
                      • 101 Posts
                      No, thank you! It helped me a lot
                        Don't believe anything you read on the net. Except this.