How do I get the last "ID" (row) created after using the "channel_form_submit_entry_end" hook? Can the hook send me the "ID"? EE5

  • Are you looking for the ID of the entry which was just created by the channel form submission? – Derek Hogue Dec 4 '18 at 17:40
  • Yes. The ID of the entry created by the channel form submission. – James Raffield Dec 4 '18 at 19:35

At the end of hook "channel_form_submit_entry_end" it is using the Channel Form Class so $obj->entry['entry_id'] a class property which is not available.

Good news is you can use the method $obj->entry('entry_id') to retrieve the entry which is one of available methods from Channel_form_lib


If you do a dump of the argument which that hooks accepts, you'll see it should contains the entry_id. I can't recall exactly what the structure looks like (it might just be $obj->entry_id or $obj['entry_id']), but do this to find out:

function channel_form_submit_entry_end($obj)
  • I used my_function($obj){ exit(var_dump($obj)); } But the entry_id is not there or set – James Raffield Dec 5 '18 at 20:32
  • Should be $obj->entry['entry_id'] ... is the submission completing successfully (showing up in the database)? – Derek Hogue Dec 6 '18 at 13:17
  • Yes. It is being created. – James Raffield Dec 6 '18 at 17:09
  • Fatal error: Uncaught Error: Cannot use object of type EllisLab\ExpressionEngine\Model\Channel\ChannelEntry this is the error I get when I try to call $ojb->entry['entry_id'] – James Raffield Dec 11 '18 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.