We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37059
    • 368 Posts
    Before I go out and code this with a hook myself... I was wondering if anyone knows of any easy solution to notify a given admin email address when someone signs up with Register?

    Thanks.
      Jason
      • 37059
      • 368 Posts
      So no one else has made a solution for this? :’(
        Jason
        • 21838
        • 284 Posts
        See the Rampart extra.
          MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
          • 37059
          • 368 Posts
          Quote from: anselmh at Aug 19, 2011, 07:01 PM

          See the Rampart extra.

          Am I missing something? I don’t see anything in the docs about admin notification.
            Jason
            • 37059
            • 368 Posts
            Hehe, turns out there's an example hook to do this very thing ]in the docs. Guess I'll use that...
              Jason
              • 36426
              • 197 Posts
              Before I go out and code this with a hook myself... I was wondering if anyone knows of any easy solution to notify a given admin email address when someone signs up with Register?

              Thanks.


              Hi Does anyone please know how to do this but only once the user has confirmed registration via email?

              Thanks very much for any help. I tried adding the posthook to [[!ConfirmRegister]] like this: [[!ConfirmRegister &postHooks=`hookComEmail`]]

              but to no avail! Thanks again for any help.
                Yorkshire UK based hosting provider: https://www.simulant.uk
                • 3749
                • 24,544 Posts
                I'm almost sure that the OnUserActivate System Event is fired by the ConfirmRegister controller, so a plugin attached to that event could send the admin an email when the user is activated.

                At that point, the username would be available with:

                $user->get('username');
                  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
                  • 36426
                  • 197 Posts
                  Quote from: BobRay at Mar 16, 2014, 07:36 PM
                  I'm almost sure that the OnUserActivate System Event is fired by the ConfirmRegister controller, so a plugin attached to that event could send the admin an email when the user is activated.

                  At that point, the username would be available with:

                  $user->get('username');

                  Hi thanks Bob, how would I make and attach a plugin to that event? I can't see that call in the snippet... I have the hook code ready which is:

                  $message = 'Hi, a new User signed up: '.$hook->getValue('username')
                   . ' with email '.$hook->getValue('email').'.';
                  $modx->getService('mail', 'mail.modPHPMailer');
                  $modx->mail->set(modMail::MAIL_BODY,$message);
                  $modx->mail->set(modMail::MAIL_FROM,'[email protected]');
                  $modx->mail->set(modMail::MAIL_FROM_NAME,'PDF Match');
                  $modx->mail->set(modMail::MAIL_SENDER,'PDF Match');
                  $modx->mail->set(modMail::MAIL_SUBJECT,'New User Registration');
                  $modx->mail->address('to','[email protected]');
                  $modx->mail->setHTML(true);
                  if (!$modx->mail->send()) {
                      $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
                  }
                  $modx->mail->reset();
                  /* tell our snippet we're good and can continue */
                  return true;


                  Thanks again for any help.
                    Yorkshire UK based hosting provider: https://www.simulant.uk
                    • 3749
                    • 24,544 Posts
                    The event invocation is not in the snippet, it's in the controller file (which hopefully executes when the user confirms registration).

                    To implement, replace the first line with this:

                    $message = 'Hi, a new User signed up: '.$user->get('username');
                    $profile = $user->getOne('Profile');
                    if ($profile) {
                       $message .= ' with email' . ' . $profile->get('email');
                    }


                    Paste the code into a plugin.

                    On the System Events tab of the plugin, check OnUserActivate. [ed. note: BobRay last edited this post 10 years, 1 month 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
                      • 36426
                      • 197 Posts
                      Hi Bob that is very clever! Unfortunately it doesn't seem to have worked. Now when I get the registration validation email, I click the link to complete my test registration and for some reason it doesn't activate me as a user...

                      Let me check that plugin again with you:

                      <?php
                      $message = 'Hi, a new User signed up: '.$user->get('username');
                      $profile = $user->getOne('Profile');
                      if ($profile) {
                         $message .= '' with email . ' . $profile->get('email');
                      }
                      $modx->getService('mail', 'mail.modPHPMailer');
                      $modx->mail->set(modMail::MAIL_BODY,$message);
                      $modx->mail->set(modMail::MAIL_FROM,'[email protected]');
                      $modx->mail->set(modMail::MAIL_FROM_NAME,'PDF Match');
                      $modx->mail->set(modMail::MAIL_SENDER,'PDF Match');
                      $modx->mail->set(modMail::MAIL_SUBJECT,'New User Registration');
                      $modx->mail->address('to','[email protected]');
                      $modx->mail->setHTML(true);
                      if (!$modx->mail->send()) {
                          $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
                      }
                      $modx->mail->reset();
                      /* tell our snippet we're good and can continue */
                      return true;


                      Did I miss something? I ticked the OnUserActivate also as you said.

                      Thanks again.
                        Yorkshire UK based hosting provider: https://www.simulant.uk