Verify dropdown/radio options

add_filter(‘frm_validate_field_entry’, ‘frm_check_radio_option’, 10, 3); function frm_check_radio_option( $errors, $posted_field, $posted_value ) { $field_ids = array( 25, 26 ); // set your field ids here if ( in_array( $posted_field->id, $field_ids ) && ! empty( $_POST[‘item_meta’][ $posted_field->id ] ) ) { $options =…Continue reading

Save the date in a different format

add_filter(‘frm_validate_field_entry’, ‘copy_my_field’, 10, 3); function copy_my_field($errors, $posted_field, $posted_value){ if ( $posted_field->id == 25 ) { //change 25 to the ID of the hidden field to change $oDate = $_POST[‘item_meta’][77]; // change 77 to the ID of your date field $_POST[‘item_meta’][$posted_field->id]…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

Change the value in a field

add_filter(‘frm_validate_field_entry’, ‘copy_my_field’, 10, 3); function copy_my_field($errors, $posted_field, $posted_value){ if ( $posted_field->id == 25 ) { //change 25 to the ID of the field to change $_POST[‘item_meta’][$posted_field->id] = $_POST[‘item_meta’][20]; //Change 20 to the ID of the field to copy } return…Continue reading

Require a minimum number of checked values

add_filter(‘frm_validate_field_entry’, ‘require_minimum_checkbox_number’, 10, 3); function require_minimum_checkbox_number( $errors, $field, $posted_value ){ if ( $field->id == 25 ) { $minimum = 4; if ( ! is_array ( $posted_value ) || ( is_array( $posted_value ) && count( $posted_value ) < $minimum ) )…Continue reading

Conditionally require a field

add_filter( ‘frm_validate_field_entry’, ‘conditionally_require_a_field’, 10, 3 ); function conditionally_require_a_field( $errors, $field, $value ) { if ( $field->id == 25 && trim( $value ) == ” ) { //change 25 to the ID of the field to require $other_field_value = $_POST[‘item_meta’][20]; //Change…Continue reading

Check for an allowed value (coupons)

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){ //change 25 to the ID of the field to validate if(!in_array($posted_value, array(‘001‘,’002‘))){ //change 001 and 002 to your allowed values //if it doesn’t match up, add an error: $errors[‘field’.…Continue reading

Create a confirmation field

add_filter(‘frm_validate_field_entry’, ‘your_custom_validation’, 20, 3); function your_custom_validation($errors, $field, $value){ if ($field->id == 31){ //change 31 to the ID of the confirmation field (second field) $first_value = $_POST[‘item_meta’][30]; //change 30 to the ID of the first field       if ( $first_value…Continue reading

Combine multiple fields into one field

add_filter(‘frm_validate_field_entry’, ‘my_custom_validation’, 8, 3); function my_custom_validation( $errors, $posted_field, $posted_value ) { if($posted_field->id == 25){ //change 25 to the ID of the destination field //change the value between the quotes to what should go in-between values $separator = “, “; $_POST[‘item_meta’][25]…Continue reading

Limit uploaded file size

add_filter( ‘frm_validate_field_entry’, ‘validate_custom_file_size’, 20, 3 ); function validate_custom_file_size( $errors, $field, $value ) { if ( $field->type == ‘file’ && ( isset( $_FILES[‘file’.$field->id] ) ) && ! empty( $_FILES[‘file’.$field->id][‘name’] ) ) { $files = (array) $_FILES[‘file’. $field->id][‘size’]; foreach ( $files as…Continue reading