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

Looking for "on entry update" hook

Development and Programming

Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly

Hi all,

I need to write an extension that sends a notification e-mail out when an entry gets updated, but I can’t seem to find a hook that gets called when the publish form is submitted.

Am I just blind or what?

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz

There is no separate update function.

New entries as well as updates are both handled by the function submit_new_entry() in cp.publish.php and the hook you are looking for will probably be “submit_new_entry_start” or “submit_new_entry_end”.

Whether it is an update you are dealing with you’ll have to figure out yourself.

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly

Thanks!

I was under the impression that that only got called on new entries. (Somewhat misleading name.)

I have no problem figuring out if it’s a new entry or not.

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz

If it is a new entry the $data-array contains the key-/value-pair ‘entry_id’ => ”. If it is an update that key is missing.

So if you take the ‘submit_new_entry_end’ hook something like this should point you into the right direction:

if ( array_key_exists("entry_id", $data) ) 
{
  //It's a new entry
} 
else 
{
  //It's an update
}
       
Brendon Carr's avatar
Brendon Carr
135 posts
17 years ago
Brendon Carr's avatar Brendon Carr

There really ought to be a hook for notifications upon update.

We’re working on a law firm site (for my law firm), and would like to have the ability to allow site visitors to request a notification if a certain article changes.

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly

“submit_new_entry_end” should do the trick, as silenz has pointed out.

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
17 years ago
Brandon Kelly's avatar Brandon Kelly

I finally got around to releasing this extension today:

http://ellislab.com/forums/viewthread/76075/

Thanks for your help, silenz!

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Hmm, this is an ancient thread but I have a question. If the entry_id key is not present in an update, how do we know which records to update in the db? I’m sure it’s a stupid question, but I don’t get it… 😕

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz
$edata = $EXT->call_extension('submit_new_entry_end', $entry_id, $data, $ping_message);

Well, the entry_id is in the 2nd argument ($entry_id) in both cases.

       

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.