Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created February 8, 2018 16:57
Show Gist options
  • Select an option

  • Save jaredatch/d368c1a243c14a3f10cbb5c2f9754d56 to your computer and use it in GitHub Desktop.

Select an option

Save jaredatch/d368c1a243c14a3f10cbb5c2f9754d56 to your computer and use it in GitHub Desktop.

Revisions

  1. jaredatch created this gist Feb 8, 2018.
    40 changes: 40 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    <?php
    /**
    * Manually run the v1.4.3 entries upgrade routine.
    *
    */
    function wpf_v143_upgrade_manual() {

    // Fetch all entries.
    $entries = wpforms()->entry->get_entries(
    array(
    'number' => -1,
    'order' => 'ASC',
    )
    );

    // Loop through the entries and add each field value to the new entry
    // fields database table.
    if ( ! empty( $entries ) ) {
    foreach ( $entries as $entry ) {
    $fields = wpforms_decode( $entry->fields );
    if ( ! empty( $fields ) ) {
    foreach ( $fields as $field ) {
    if ( isset( $field['id'] ) && isset( $field['value'] ) && '' !== $field['value'] ) {
    wpforms()->entry_fields->add(
    array(
    'entry_id' => absint( $entry->entry_id ),
    'form_id' => absint( $entry->form_id ),
    'field_id' => absint( $field['id'] ),
    'value' => $field['value'],
    'date' => $entry->date,
    )
    );
    }
    }
    }
    }
    }

    delete_option( 'wpforms_fields_update' );
    }