Limit number of uploaded files

add_filter(‘frm_validate_field_entry’, ‘validate_number_of_files’, 10, 3); function validate_number_of_files($errors, $field, $value){ if ( in_array($field->id, array(25,26,27)) && $field->type == ‘file’ && (isset($_FILES[‘file’.$field->id])) && !empty($_FILES[‘file’.$field->id][‘name’])){ $files = (array)$_FILES[‘file’. $field->id][‘name’]; $count = 0; foreach($files as $n){ if(!empty($n)) $count++; } $existing = $_POST[‘item_meta’][$field->id]; if($existing){ foreach($existing as $e){…Continue reading

Limit the number of times a date can be selected

add_filter(‘frm_validate_field_entry’, ‘my_custom_validation’, 10, 3); function my_custom_validation($errors, $posted_field, $posted_value){ if($posted_field->id == 125 and !is_admin()){ //change 125 to the ID of the date field $frmpro_settings = FrmProAppHelper::get_settings(); $selected_date = FrmProAppHelper::convert_date($posted_value, $frmpro_settings->date_format, ‘Y-m-d’); //get all the entries for that date $entries_for_date = FrmEntryMeta::get_entry_metas_for_field(125,…Continue reading

Limit responses for a set time period

add_filter(‘frm_validate_field_entry’, ‘my_custom_validation’, 10, 3); function my_custom_validation($errors, $posted_field, $posted_value){ if($posted_field->id == 25 and !is_admin()){ //change 25 to thema ID of the field to validate global $wpdb; $entry_id = (isset($_POST[‘id’])) ? $_POST[‘id’] : 0; $entries = $wpdb->get_col($wpdb->prepare(“SELECT item_id FROM ” . $wpdb->prefix…Continue reading

Hide a field depending on a value in another

add_filter(‘frm_field_type’, ‘change_my_field_type’, 10, 3); function change_my_field_type($type, $field, $value){ if($field->id == 25){ //change 25 to the id of the field to conditionally hide global $my_required_id, $user_ID; if($my_required_id == $user_ID) //if current user is not an editor $type = ‘hidden’; //hide this…Continue reading

Order options by entry ID

add_filter(‘frm_data_sort’, ‘frm_my_data_sort’, 21, 2); function frm_my_data_sort( $options, $atts ) { if ( $atts[‘dynamic_field’][‘id’] == 100 ) { //change 100 to the ID of the Dynamic field ksort( $options );//sorts options by entry ID } return $options; }Continue reading

Remove duplicates from Dynamic field

add_filter(‘frm_data_sort’, ‘frm_remove_duplicates’, 21, 2); function frm_remove_duplicates( $options, $atts ) { if ( $atts[‘dynamic_field’][‘id’] == 100) { //change 100 to the ID of the Dynamic field $options = array_unique( $options ); } return $options; }Continue reading

Add custom option set

add_filter(‘frm_bulk_field_choices’, ‘add_custom_frm_options’); function add_custom_frm_options( $opts ){ $opts[‘Set Name’] = array(‘Option 1’, ‘Option 2’, ‘Option 3’); return $opts; }Continue reading

Only include categories with no parent

add_filter(‘frm_get_categories’, ‘frm_order_cats’, 10, 2); function frm_order_cats($args, $field){ if($field[‘id’] == 25){ //change 25 to the ID of your field $args[‘parent’] = 0; } return $args; }Continue reading

Blackout Time Blocks

add_filter(‘frm_allowed_times’, ‘change_my_business_hours’, 10, 2); function change_my_business_hours($remove, $values) { if ( $values[‘time_field’] == ‘field_mflcim’) { //change to field key for your time field $week_day = date(‘l’, strtotime($values[‘date’])); $times_to_remove = array( ‘Monday’ => array(’05:15 PM’, ’05:30 PM’, ’05:45 PM’, ’06:00 PM’), //continue…Continue reading

Change to like

add_filter( ‘frm_set_comparison_type_for_lookup’, ‘customize_lookup_value_retrieval’, 10, 3); function customize_lookup_value_retrieval( $type, $parent_field, $child_field ) { if ( $parent_field->id == 123 ) { $type = ‘like’; } return $type; }Continue reading