Is there a way to have MODx send me (site admin) and email whenever a web user logs in?
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
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!
I modified the post above, see if that helps
Fantastic! Thank you so much.
Going to try it now...
Awesome _plugin_ Can it be set to a specific webuser’s login? I must learn PHP...
Edit: Really not necessary... Awesome plugin!!!