We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6531
    • 154 Posts
    Is there a way to have MODx send me (site admin) and email whenever a web user logs in?
      • 4041
      • 788 Posts
      You could create a new plugin that reacts OnWebLogin

      <?php
      /*  blank_plugin
      
             Note that the start and end php tags breaks the plugin
             and are there only for highlighting purposes
      */
      // Handle event
      $e = &$modx->Event;
      switch ($e->name) {
      case "OnWebLogin":
      $Name = "MODx Admin"; //senders name
      $email = "[email protected]"; //senders e-mail adress
      $recipient = "[email protected]"; //recipient
      $mail_body = $_SESSION['webFullname']." logged in..."; //mail body
      $subject = "Subject for reviever"; //subject
      $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
      
      mail($recipient, $subject, $mail_body, $header); //mail command 
        break;
      
      case "OnWebLogout":
        // code here
        break;
      
      //case "":
        // code here
      //  break;
      
      default: "";
      
        return;
      }
      ?>


      * make sure you check the OnWebLogin event on the System Events tab

      edit: modify the fields to suit your situation and see if it works
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 6531
        • 154 Posts
        That looks great!
        ... but I’m a bit too green to fill in the "// add your email code here"

        What’s the simplest way to do that?
        I just want an email that says "so and so logged in"

        Thanks!
          • 4041
          • 788 Posts
          I modified the post above, see if that helps smiley
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 6531
            • 154 Posts
            Fantastic! Thank you so much.
            Going to try it now...
              • 6531
              • 154 Posts
              YAY! It works! THANKS!
                • 20413
                • 2,877 Posts
                Awesome _plugin_ Can it be set to a specific webuser’s login? I must learn PHP...  tongue

                Edit: Really not necessary... Awesome plugin!!!
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower