Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Created September 23, 2024 15:53
Show Gist options
  • Save vfontjr/e45218e949070a4c9409d96d7c96d060 to your computer and use it in GitHub Desktop.
Save vfontjr/e45218e949070a4c9409d96d7c96d060 to your computer and use it in GitHub Desktop.
<?php
function create_init_field_vars_array( $form_key ) {
global $wpdb;
/* initialize the variables for the formidable tables */
$wpdb_prefix = $wpdb->prefix;
$frm_fields = $wpdb_prefix . 'frm_fields';
$form_id = FrmForm::get_id_by_key( $form_key );
$new_key = str_replace('-', '_', $form_key);
$init_form_vars_array[$new_key] = $form_id;
$sql = "SELECT field_key, id FROM `{$frm_fields}` where form_id='{$form_id}' order by field_order;";
$results = $wpdb->get_results( $sql );
if( $results ) {
foreach( $results AS $field_entry ) {
$init_form_vars_array[$field_entry->field_key] = $field_entry->id;
}
}
return $init_form_vars_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment