I have realized, there is indeed no Submission ID before the form is sent. Logical 😀
Looking for a workaround now…
Solved.
This code catches entry_id after submission, adds it to the response and lets me use the new placeholder {submission_id} in the success message or redirect.
add_action( 'plugins_loaded', 'wpmudev_forminator_add_entry_id_to_response', 100 );
function wpmudev_forminator_add_entry_id_to_response() {
if ( class_exists( 'Forminator' ) ) {
class WPMUDEV_Forminator_Add_Entry_ID_To_Response {
private $form_id = 711; // CHANGE THE FORM ID HERE
private $entry_id = ''; // Set default value as empty string
public function __construct() {
add_action( 'forminator_custom_form_submit_before_set_fields', array( $this, 'retrive_entry_id' ), 10, 2 );
add_filter( 'forminator_replace_form_data', array( $this, 'add_entry_id_to_response' ), 10, 3 );
}
public function retrive_entry_id( $entry, $form_id ) {
if ( $this->form_id == $form_id ) {
$this->entry_id = $entry->entry_id ?? 'N/A'; // Fallback to 'N/A' if null
error_log('Submission ID stored: ' . $this->entry_id); // Debugging
}
}
public function add_entry_id_to_response( $content, $data, $original_content ) {
if ( strpos( $content, '{submission_id}' ) !== false ) {
$replacement = !empty($this->entry_id) ? $this->entry_id : 'N/A';
error_log('Replace {submission_id} with: ' . $replacement);
$content = str_replace( '{submission_id}', $replacement, $content );
}
return $content;
}
}
$run = new WPMUDEV_Forminator_Add_Entry_ID_To_Response;
}
}
After adding it, I can use https://example.com/step-2/?entry={submission_id} as redirect URL in Behavior settings.
It also allows to print out entry ID in the success message like this:
Your submission ID: {submission_id}.