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 = '[email protected]';
$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('[email protected]');
$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_emailThanks in advance, Aharon
Moved to Plugins Forum by Moderator
Clarification of previous posting. The hook submit_new_entry_end invokes my extension when a new record is added to the weblog via the Publish tab in the ControlPanel. However the hook is ALSO invoking my extension when that record is edited in the Edit tab of the Control Panel.
Is this the intended functionality of this hook, if so the name ‘submit_new’ is misleading. If so, how can I trigger my extension’s method ONLY when a new record is added, not when being edited?
Thanks, Aharon
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.