Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created June 23, 2017 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/218307925147525a4e0a772a6637ac47 to your computer and use it in GitHub Desktop.
Save Shelob9/218307925147525a4e0a772a6637ac47 to your computer and use it in GitHub Desktop.
Code example of how to resend all messages of a form from Caldera Forms See: https://calderaforms.com/doc/resend-caldera-forms-messages/
<?php
add_action( 'init', function(){
//This is a key to track which page were on of resend using option table
$page_key = '_my_cf_resend_page_key';
//Get current page of entries to resend
$current_page = get_option( $page_key, 1 );
if( 0 == $current_page ){
//stop beacuse we're done.
//probably should remove this code now
return;
}
//IMPORTANT: Update to match your form ID
$form = Caldera_Forms_Forms::get_form( 'CF59442cd3f31d9' );
$entries_object = new Caldera_Forms_Entry_Entries( $form, 5 );
$entries = $entries_object->get_page( $current_page );
if( empty( $entries ) ) {
update_option( $page_key, 0 );
//All done!
return;
}
/** @var Caldera_Forms_Entry $entry */
foreach ( $entries as $entry ){
$entry_id = $entry->get_entry_id();
$resender = new Caldera_Forms_Email_Resend( $entry_id, $form );
$resender->resend();
}
//mark page as 1 more
update_option( $page_key, $current_page + 1 );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment