On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi All,

    Really hope you can help. I’m using the WebLogin feature to get users to sign-up and gain access to members only pages within the site, this is working a treat, once they sign-up the admin then ticks a box on the Web Users details within the manager to give them full access. The only problem I’m have is getting the email notification to be sent to the administrator of the site as well as the new member, this way they know when a user has signed up, they can validate the details and then tick that magic box to activate the account.

    Does anyone know how I can do this by modifying the websignup.inc.php file?

    • Instead of modifying the files, create a plugin with the following code (modify the settings to your purpose) and check the OnWebSaveUser event.

      <?php // remove this line - it's only here for code highlighting purposes
      /*     EmailAdmin_plugin.php
      // check the OnWebSaveUser event
      These are the available variables you can use/send in the email
      $mode ="new";
                                  "mode"         => "new",
                                  "userid"       => $key,
                                  "username"     => $username,
                                  "userpassword" => $password,
                                  "useremail"    => $email,
                                  "userfullname" => $fullname
      // set up a comma delimited list of the address(s) which will receive the notifications
      $recipient_email_array = array("me@mywebsite.com","anotherperson@anotheremail.com");
      // set up the content of the message
      $email_content_string =$userfullname." has created a new account.\n Please login to the manager and verify the account.";
      // Handle event
      $e = &$modx->Event;
      switch ($e->name) {
      case "OnWebSaveUser":
            if($mode =="new"){
                  $countarray = count($recipient_email_array);
                  if($countarray > 0 ){
                      foreach ($recipient_email_array as $rea){
                          // send html email receipt to admin(s)
                          mail($rea, 'New Webuser Account',
                          "From: Admin Name <admin@yoursite.com>\n" .
                          "MIME-Version: 1.0\n" .
                          "Content-type: text/html; charset=iso-8859-1");
      default: "";
        http://frsbuilders.net (under construction) forum for evolution
      • Hello Breezer ... I just implemented the plugin you have above on a MODx 1.02 site and it does not send the Admin an email. Have you tried this out on this MODx version yet? Any insight would be awesome ... thanks!
          Precision Web Development ... SmashStack.com
        • Update ... not sure what was wrong, but I just started over with the code and now it’s working fine smiley
            Precision Web Development ... SmashStack.com
          • Also, if you want to add extra fields from your form, you can do so by adding to the list in the /assets/snippets/weblogin/websignup.inc.php file (under the // invoke OnWebSaveUser event area.

            For example, I’ve added a few such as:

            "usercountry" => $country, (need some extra coding to pull through the country name from the country code in the plugin)
            "userzip" => $zip,
            "usercomment" => $comment

            And I’ve been able to pull them through to the email without a problem.

            Great plugin!
            • I tried this plugin and it didn’t work for me. I’m a little confused as to what modifications should be changed. All I changed is the email addresses in the "set up a comma delimited list of the address(s) which will receive the notifications" section. Also do I just remove the top line next to <?php or all the commented out lines below <?php to Modifible Settings?
              • Get rid of the <?php... line. Plugins don’t like that. It’s only there in the displayed code to activate the forum’s syntax highlighting.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                • Did you check OnWebSaveUser on the events tab for the plugin?

                  Also you should modify this part:
                  "From: Admin Name <admin@yoursite.com>\n" .

                    http://frsbuilders.net (under construction) forum for evolution
                  • Hi breezer,

                    This is exactly what I want. It's awesome! Thank you very much for posting such a useful plugin!

                    May I post it on my website http://modx.jp.net/snippets/community/emailadmin.html with some Japanese translation where necessary? [ed. note: Tomophy last edited this post 8 years, 6 months ago.]
                    • I see no problem at all, glad it is useful smiley
                        http://frsbuilders.net (under construction) forum for evolution