I am writing an extension. The goal is that when we use Publish in Control Panel to add a new entry to a specific weblog, one email will be sent to the email address specified in a custom field as a notification message.
Then extension has priority ‘1’ for the submit_new_entry_end hook. My method called by the hook instantiates the EEmail class and sets the parameters as per the documentation.
Sporadically, multiple emails are being generated, a few minutes apart, resulting from the same Publish event. Could one submission from the Publish page be calling the extension multiple times?
Has anyone seen such a phenomenon, suggest anything?
Here is the code of the function invoked by submit_new_entry_end hook:
function send_job_post_email() {
global $DSP, $SESS, $PREFS, $FNS, $DB, $LANG;
$argl=func_get_args();
if ($argl[1]["weblog_id"] == "53" && $argl[1]["status"]=="open" && $_POST['field_id_333'] != "") {
// create the email class
if ( ! class_exists('EEmail')) {
require PATH_CORE.'core.email'.EXT;
}
$EML = new EEmail;
//$message_to = $_POST['field_id_333']; //jobs_contact_email
$message_to = 'avalidemailaddress@gmail.com';
$message_text = 'Thank you for forwarding your job(s) to us for posting' ;
// create the email
//$EML->from($PREFS->ini('webmaster_email'));
$EML->mailtype= 'html';
$EML->initialize();
$EML->from('yyy@ourcompany.org');
$EML->to($message_to);
$EML->subject('Your job has been posted: ' . $argl[1]["title"]);
$EML->message($message_text);
$EML->send();
} // end if status open
} // end function send_job_post_email
Thanks in advance,
Aharon
Moved to Plugins Forum by Moderator
