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

How I can differ publishing a new entry and editing existing entry?

Development and Programming

stryzo's avatar
stryzo
1 posts
about 15 years ago
stryzo's avatar stryzo

Hello,

I want to create two hooks, one for first publishing entry (content/publish) and second for editing an existing entry (content/edit).

I used “entry_submission_absolute_end”, but it works in both cases. How can I differ between this two cases?

       
Rick Jolly's avatar
Rick Jolly
729 posts
about 15 years ago
Rick Jolly's avatar Rick Jolly

I’m not sure if an entry_id is populated before the “entry_submission_absolute_end” hook. But, if you use the “entry_submission_ready” hook, you’ll notice that entry_id is an empty string when creating a new entry - so that is one way to differentiate between creating and editing.

       
Yuri's avatar
Yuri
315 posts
14 years ago
Yuri's avatar Yuri

In case anyone needs the solution: you need to check $this->data array passed by “entry_submission_absolute_end” hook For existing enries, $this->data[‘entry_id’] contains proper entry_id, for new entries it’s zero So simply do simething like

if ($data['entry_id']!=0)
{
    return false;//this is existing entry
}
       

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.