EllisLab text mark
Advanced Search
     
submit_new_entry_end hook triggered multiple times from one publish?
Posted: 28 May 2010 04:53 PM   [ Ignore ]
Joined: 2009-03-30
19 posts

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

 
Posted: 28 May 2010 05:29 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2002-04-29
26055 posts

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

 
Posted: 01 June 2010 06:16 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-03-30
19 posts

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