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
2 Answers
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)
{
exit(var_dump($obj));
}
-
I used my_function($obj){ exit(var_dump($obj)); } But the entry_id is not there or set Dec 5, 2018 at 20:32
-
Should be
$obj->entry['entry_id']
... is the submission completing successfully (showing up in the database)? Dec 6, 2018 at 13:17 -
-
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'] Dec 11, 2018 at 14:22