hi there
i’ve created a custom extension plugging into User’s user_register_end hook to create a new blank entry on registration of a certain member group, with the new member_id as the author_id, using submit_new_entry but I get “You are not authorized to post in this channel” error.
I’ve set the group’s permissions to allow posting in the appropriate channel but on registration but I’m making the assumption that this error occurs because the user has not actually logged in yet.
So my question is really this: is it actually possible to create a blank entry (with just the essential fields supplied) using the API in a channel that’s normally locked down to logged in users?
Here’s the appropriate code in my extension:
$this->EE->load->library('api');
$this->EE->api->instantiate('channel_entries');
$data = array(
'title' => $user_object->insert_data['screen_name'],
'site_id' => '1',
'entry_date' => $this->EE->localize->now,
'author_id' => $member_id
);
if ($this->EE->api_channel_entries->submit_new_entry(1, $data) === FALSE) {
show_error('An Error Occurred Creating the Entry');
}the hook is passing the member_id and data object just fine but is there anything wrong with this or is there something else i need to do in order to get this to work.
thanks!
Moved to Development and Programming by Moderator
Here’s an update on this:
To get around this problem I simply moved the user_register_end hook to after the new session is created and the new user is logged in (in mod.user.php, “reg” function)
Clearly not the best solution I know, so if there are any better ways without changing the User core please holler!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.