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

Trying to get entry_id value after a SafeCracker submit

Development and Programming

Jeri Letman's avatar
Jeri Letman
23 posts
14 years ago
Jeri Letman's avatar Jeri Letman

I’m using SafeCracker to submit posts.

EE v2.2.0

After a post has been submitted I need to retrieve the entry id for the post that was just submitted.

I created an extension using the hook - safecracker_submit_entry_end

the extension is very simple right now. These lines of code are outputting on the screen after a submission.

$member_id = ee()->session->userdata['member_id'];
  echo "Member ID: $member_id
";
  echo "Entry ID: " .     $this->entry_id;

The member ID is correct, but there is no value for $this->entry_id

I’m not sure if I’m doing something incorrect, or if the entry id hasn’t been created yet.

Any suggestions on how I can get the entry id greatly appreciated.

Thanks.

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

Try this:

//your extension method
public function _submit_end($safecracker) 
{
    $entry_id = $safecracker->EE->api_sc_channel_entries->entry_id;
}
       
Jeri Letman's avatar
Jeri Letman
23 posts
14 years ago
Jeri Letman's avatar Jeri Letman

Hi,

That didn’t work for me. Thank you for the suggestion.

I was able to get it to work with the following.

function mod_post($auto_data)
{
    $this->EE =& get_instance();
    
    $auto_entry = $auto_data->entry;
    $entry_id = $auto_entry['entry_id'];
       

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.