<?php
//Get document info
global $modx;
$data = $modx->documentObject['createdby'];
$author = substr($data,1);
$table = $modx->getFullTableName("web_user_attributes");
//Get Creator email address
$db_query = $modx->db->select("email", $table, "id = $author");
return $db_query;
?>if ($modx->db->getRecordCount($db_query) > 0) {
while ($row = $modx->db->getRow($db_query)) {
//do something more meaningful with the row here
echo $row['email'];
}
}
$email = $modx->db->getValue('SELECT email FROM '.$table.' WHERE internalKey='.$author);
return $email;
MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’’ at line 1 »
SQL: SELECT email FROM `indieoph_modx`.`modx_web_user_attributes` WHERE internalKey =
// Handle event
$e = &$modx->Event;
switch ($e->name) {
case "OnDocPublished":
global $modx;
$data = $modx->documentObject['createdby'];
$author = substr($data,1);
$table = $modx->getFullTableName("web_user_attributes");
//Get Creator details
$db_query = $modx->db->select("email", $table, "internalKey = $author");
$db_results = $modx->db->getRow($db_query);
$Name = "Indieophile"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipient = $db_results['email']; //recipient
$mail_body = "your post has been published. See it at http://www.indieophile.com/"; //mail body
$subject = "your indieophile post has been published"; //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;
}$doc = $modx->getDocument($_GET['id'], '*', 1); $author =$doc['createdby'];
// Handle event
$e = &$modx->Event;
switch ($e->name) {
case "OnDocPublished":
//Get document info
global $modx;
$page_id = $modx->getPageInfo($docid);
$content_table = $modx->getFullTableName("site_content");
$web_user_table = $modx->getFullTableName("web_user_attributes");
$data = $modx->db->getValue('SELECT createdby FROM '.$content_table.' WHERE id='.$page_id['id']);
$author = substr($data,1);
$address = $modx->db->getValue('SELECT email FROM '.$web_user_table.' WHERE internalKey='.$author);
$full_name = $modx->db->getValue('SELECT fullname FROM '.$web_user_table.' WHERE internalKey='.$author);
$Name = "Indieophile"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipient = $address; //recipient
$mail_body = $full_name.", your post, ".$page_id['pagetitle']. ", has been published. See it at http://www.indieophile.com/".$page_id['alias']; //mail body
$subject = "your post has been published"; //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;
}