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"?

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

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)
{
    exit(var_dump($obj));
}
  • I used my_function($obj){ exit(var_dump($obj)); } But the entry_id is not there or set – James Raffield Dec 5 at 20:32
  • Should be $obj->entry['entry_id'] ... is the submission completing successfully (showing up in the database)? – Derek Hogue Dec 6 at 13:17
  • Yes. It is being created. – James Raffield Dec 6 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 at 14:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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