We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

API submit_new_entry - "You are not authorized to post in this channel"

Development and Programming

David Hyland's avatar
David Hyland
210 posts
15 years ago
David Hyland's avatar David Hyland

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

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

Hi, davidhyland. I’m going to move this over to the Development forum, since it’s more on topic there.

       
David Hyland's avatar
David Hyland
210 posts
15 years ago
David Hyland's avatar David Hyland

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!

       
spyro's avatar
spyro
89 posts
14 years ago
spyro's avatar spyro

Did you ever locate a better solution for this?

       
David Hyland's avatar
David Hyland
210 posts
14 years ago
David Hyland's avatar David Hyland

Sorry no, I didn’t spend any more time trying to figure it out.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.