//Get Entry ID of a field and then return another fields value based on that ID (Within the same form)
function getLinkedFormData( $atts ) {
global $wpdb;
$field_id = $atts['field_id']; //Field ID used to capture the entry_id of the original entry
$where_value = $atts['where_value']; //Must be unique. A 'primary key' value that is used to link forms by a certain field value
$associated_field_id = $atts['associated_field_id']; //Field ID of a field in the original entry that is not the same as $field_id above
$getEntryID = $wpdb->get_var( $wpdb->prepare("SELECT item_id FROM ". $wpdb->prefix ."frm_item_metas WHERE field_id = %d AND meta_value = %s", $field_id, $where_value) );
return FrmProEntriesController::get_field_value_shortcode(array('field_id' => $associated_field_id, 'entry' => $getEntryID));
}
add_shortcode( 'get_frmlinked_data', 'getLinkedFormData' );
Example: [get_frmlinked_data field_id=256 where_value="Unique Entry Text Here" associated_field_id=258]
This looks for the Entry ID for the entry that contains the value "Unique Entry Text Here" and then returns any field value from within that same Entry ID as defined by the "associated_field_id". This is sort of an alternative to frm_field_value where you might need to have a where query and also certain types of views where you're only trying to capture 1 particular field value in an entry.
The only caveat here is that this will only return a single value referenced from an existing unique value. It does not return an array of values or have a way to determine a specific value from a array of values.
Sorry I missed this. The code is limited, but this is the just of it: The "where_value" is a specific value that you will set that is a unique value to field 256. Example: I know that 256 has a unique value of "finance". Then it will find the value of field 258 in that same entry and display that back. Example: If within an entry field id 258 is 3000, where that entry for for 256 equals "finance", then that is the result this code would return the value of 3000.
Please login or Register to submit your answer
Ah very useful!