I hope that I can explain this succinctly. Platform is EE 2.10.1 (this is a sandbox, live version will be on 2.11.1).
I am working on an extension which is using Solspace's User Module's user_register_end hook. After entering the user to the member list, we need to process company information into the Companies channel.
I am achieving this by loading the channel entries and channel fields API and then calling the save_entry method:
ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');
No problem so far. However, I need to process the information further and require the ID of the newly created company entry.
As far as I see, the save_entry method is only returning a success boolean - not the ID of the successfully created channel entry. First thought was to load the channel_entries_model to get the channel entry by field name. But get_entry only accepts the entry ID, which I don't have. Then I reckoned, I could use the get_recent_entries method of the channel_entries_model. However, when I run it I get the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: EE::$cp
Filename: core/Model.php
Line Number: 50
Fatal error: Call to a member function allowed_group() on a non-object in /var/www/html/system/expressionengine/models/channel_entries_model.php on line 189
How can I get the ID of the channel entry that has just been created through the API? I can create a custom query using Codeigniter - but would rather not.
Thanks for guidance and help.