Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active December 29, 2018 02:12
Show Gist options
  • Save Shelob9/d44419d0218116f74097d77dd84929e3 to your computer and use it in GitHub Desktop.
Save Shelob9/d44419d0218116f74097d77dd84929e3 to your computer and use it in GitHub Desktop.
Example code for reading, updating and deleting Caldera Forms entries. See: https://calderaforms.com/doc/edit-caldera-forms-entries-php/
<?php
//delete all saved Caldera Forms
$forms = Caldera_Forms_Forms::get_forms( false, true );
if( ! empty( $forms ) ){
foreach( $forms as $form ){
Caldera_Forms_Forms::delete_form( $form );
}
}
<?php
/**
* Delete one Caldera Forms entry
*/
Caldera_Forms_Entry_Bulk::delete_entries( array( 42 ) );
/**
* Delete multiple Caldera Forms entries
*/
Caldera_Forms_Entry_Bulk::delete_entries( array( 42, 88 ) );
<?php
//Make sure to change these IDs to match your needs
$form_id = 'CF58a360bf5803c';
$entry_id = 301;
$field_to_edit_id = 'fld_6856345';
//get form
$form = Caldera_Forms_Forms::get_form( $form_id );
//Get form entry
$entry = new Caldera_Forms_Entry( $form, $entry_id );
//get all fields
$fields = $entry->get_fields();
//Get field object of field to edit
$field_to_edit = $entry->get_field( $field_to_edit_id );
//Change fields value
$field_to_edit->value = 'fff';
//Put modified field back in entry
$entry->add_field( $field_to_edit );
//Save entry
$entry->save();
<?php
//Make sure to change these IDs to match your needs
$form_id = 'CF58a360bf5803c';
$entry_id = 301;
$field_to_edit_id = 'fld_6856345';
//Update value of one field
Caldera_Forms_Entry_Update::update_field_value( $field_to_edit_id, $entry_id, 'Hi Shawn' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment