How to get the entry ID

Created by Phil Kurth, Modified on Wed, 20 Dec 2023 at 10:25 AM by Phil Kurth

Form entries are posts under the hood. When storing entry posts, you may access the created entry ID in a custom submission handler as follows: 


<?php

add_action( 'af/form/submission', function ( $form, $field, $args ) {
  
  // If we need to run this only on a specific form, check for the form key.
  if ( $form['key'] !== 'form_5bfcef8b5a540' ) {
    return;
  }

  $entry_id = AF()->submission['entry'] ?? null;

  // Use the entry ID as needed here.

}, 10, 3 );

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article