Created
June 23, 2017 02:10
-
-
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/
This file contains 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 | |
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