We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I am setting up a registration page using Login for a site where users will not be allowed to be automatically registered. All users need to be moderated.

    I have set up an email chunk for registration reflecting that membership will be reviewed and a further email either accepting or rejecting their application will be forthcoming. I would also want to send an automatic email to the site administrator to let her know that there is a new user to moderate - how could I do this?

    The new registerant is listed under the Security ->Manager Users and it is easy to simply check to active a user, however, I want to be able to send the relevant email to the user reflecting acceptance or rejection. I have tried to send a message via User -> Messages but the messages don’t appear to go anywhere and are not even listed.

    Any suggestions as to how I can make these things work?

    Thanks in advance.... huh
      Helen Warner
      Number one pixel!
      Proud to be linked with MODX at Crimson Pixel
    • Ok, I’ve come across Pre and Post Hooks and can now do Custom Register Email to send an email to site administrator, so that’s one thing ticked off my requirements. See here for the answer http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks.

      Still need a way of sending messages to users from within Manager.
        Helen Warner
        Number one pixel!
        Proud to be linked with MODX at Crimson Pixel
      • Ok have tried getting the hook to work but without much success anyone else had any joy with this?

        Thanks
          Helen Warner
          Number one pixel!
          Proud to be linked with MODX at Crimson Pixel
        • Managed to get this to work after all - there is a typo on the Pre and Post Hooks page, the snippet call is shown as:

          [[!Register? &postHook=`hookComEmail`]]

          which doesn’t work - there needs to be an ’s’ at the end of &postHook like this

          [[!Register? &postHooks=`hookComEmail`]]

          Cool, got it to work.
            Helen Warner
            Number one pixel!
            Proud to be linked with MODX at Crimson Pixel
          • Still haven’t been able to establish a way of notifying a new user automatically when ’active’ is manually checked in their profile - I realise an email can be sent manually but it would be good to be able to have a way of doing this automatically so if a user is accepted and activate they receive a ’Success’ reply or if not activation a ’Rejected’ reply.

            Anyone suggest a way. huh

            Thanks
              Helen Warner
              Number one pixel!
              Proud to be linked with MODX at Crimson Pixel
              • 3749
              • 24,544 Posts
              Quote from: Muggins at Nov 29, 2010, 09:24 AM

              Still haven’t been able to establish a way of notifying a new user automatically when ’active’ is manually checked in their profile - I realise an email can be sent manually but it would be good to be able to have a way of doing this automatically so if a user is accepted and activate they receive a ’Success’ reply or if not activation a ’Rejected’ reply.

              Anyone suggest a way. huh

              Thanks

              I think it could be done with a plugin tied to OnBeforeUserFormSave. You’d have to compare the ’active’ field to $scriptProperties[’active’]. It might look something like this (but it could be a struggle to get it working -- debugging mail code inside a plugin is no fun -- don’t say I didn’t warn you):

              <?php
              /* EmailOnActivation plugin */
              
              if ($mode == modSystemEvent::MODE_UPD) {
                if ( (!$user->get('active')) && $scriptProperties['active']) { // status is changing to active
                    /* send email here */
                    $profile = $user->getOne('Profile');
                    if ($profile) {
                         $email = $profile->get('email');
                    }
                    // etc.
                }
              }
                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
              • Thanks BobRay, I will give it a go and see how I get on.

                I’ll give you an update. I’ve also being trying to get to grips with the security of Modx and found your walk through regarding Permissions, I’m not sure I fully understand it yet, but will re-read until the fog lifts and I see it more clearly laugh

                Bob’s Guide can be found here http://bobsguides.com/revolution-permissions.html

                Did notice a suggestion that Revolution 2.0.5 is due out soon which may clarify the back end?
                  Helen Warner
                  Number one pixel!
                  Proud to be linked with MODX at Crimson Pixel
                  • 3749
                  • 24,544 Posts
                  Quote from: Muggins at Nov 30, 2010, 07:41 AM

                  Did notice a suggestion that Revolution 2.0.5 is due out soon which may clarify the back end?
                  The only significant change I’ve noticed is the addition of Policy Templates, but there could be other changes I don’t know about. Using Policy Templates means that you can enable and disable specific permissions in a policy by checking or unchecking a checkbox in the policy. It’s a great convenience and it’s much more reliable (and less scary) than manually adding and removing permissions. AFAIK, however, the basic concepts of protection, contexts, policies, permissions and the various ACLs are unchanged and that’s what most people have trouble with.

                  Let me know if you have any suggestions on improving the Permissions section at Bob’s Guides. People who are just learning are by far the best source of information about where the documentation is weak.
                    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
                  • Ok gave the plugin a try and it didn’t do anything - have I added some syntax incorrectly?
                    <?php
                    /* EmailOnActivation plugin */

                    if ($mode == modSystemEvent::MODE_UPD) {
                    if ( (!$user->get(’active’)) && $scriptProperties[’active’]) { // status is changing to active
                    /*[[+registrationAcceptance]]*/
                    $profile = $user->getOne(’Profile’);
                    if ($profile) {
                    $email = $profile->get(’email’);
                    }
                    // etc.
                    }
                    }

                    Not great at php - but I’m prepared to learn.....

                    I did remove the /* */ but this caused all code to go red and nothing happened anyway! laugh

                    Any other suggestions.. or is there another way of coming at this problem? Users have to be approved for access to this website and it isn’t open to just anyone, so manual activation is required. I know it is possible as I use it with a Vanilla forum I have running on another site.

                    Thanks wink
                      Helen Warner
                      Number one pixel!
                      Proud to be linked with MODX at Crimson Pixel
                      • 3749
                      • 24,544 Posts
                      I’d be embarrassed to say how long this took me, but this plugin definitely works (linked to OnBeforeUserFormSave):

                      <?php
                      if ($mode == modSystemEvent::MODE_UPD) {
                          if ( ! $user->get('active') && $_POST['active'] ) { 
                              $modx->logManagerAction('activate_user','modUser',$user->get('id'));
                              $email = $_POST['email']; 
                              /* Code to Send email goes here */
                          }
                      }


                      Paste the code into the plugin so you don’t have to worry about typos.

                      The logManagerAction line is optional. It will put a line in the Manager Action log (Reports->Manager Actions) so you can confirm that the user was activated and exactly when.
                      The code, as is, does nothing except put the line in the log because there’s no code to send the email.

                      I strongly advise you to work on the code to send the email in a snippet, not a plugin. Plugins are notoriously hard to debug and a typo can make the user save hang (reload the page if that happens). Once it’s working, paste it into the plugin.

                      The code above will not send an email if you create a new activated user in the Manager (even if you take out the first if statement). It only executes when you update an existing user. If you’d like it to do that too, let me know.


                        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