Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Track Caldera Forms entry ID in user meta so form can be used as editor for previous submission https://calderaforms.com/doc/edit-caldera-forms-entries/
<?php
/**
* On form load, check for a saved entry for current user
*/
add_filter( 'caldera_forms_render_entry_id', function ( $entry_id, $form ){
//change form ID to match your form
if( 'CF1234567' == $form[ 'ID' ] && get_current_user_id() ){
$saved_entry_id = get_user_meta( get_current_user_id(), 'form_entry_id' );
if( 0 < absint( $saved_entry_id ) ){
$entry_id = $saved_entry_id;
}
}
return $entry_id;
}, 10, 2);
/**
* On form submit, save the entry ID as user meta
*/
add_action( 'caldera_forms_submit_complete', function( $form, $form_link_array, $process_id, $entry_id ){
//change form ID to match your form
if( 'CF1234567' == $form[ 'ID' ] && get_current_user_id() ){
update_user_meta( get_current_user_id(), 'form_entry_id', $entry_id );
}
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.