We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

submit_new_entry_end hook triggered multiple times from one publish?

Development and Programming

grenadir's avatar
grenadir
9 posts
15 years ago
grenadir's avatar grenadir

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_email

Thanks in advance, Aharon

Moved to Plugins Forum by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

Aharon, we don’t provide direct support for writing plugins. Moved to the Plugins for additional community support.

       
grenadir's avatar
grenadir
9 posts
15 years ago
grenadir's avatar grenadir

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

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.