-
-
Save Shelob9/3e90d6a905b4ddc8c997a9929227f38d to your computer and use it in GitHub Desktop.
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', true ); | |
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