Copy text value from Dynamic field

add_filter(‘frm_validate_field_entry’, ‘copy_my_dynamic_field’, 10, 3); function copy_my_dynamic_field( $errors, $posted_field, $posted_value ) { if ( $posted_field->id == 125 ) { $_POST[‘item_meta’][ $posted_field->id ] = FrmProEntriesController::get_field_value_shortcode( array( ‘field_id’ => 50, ‘entry’ => $_POST[‘item_meta’][120] ) ); } return $errors; }Continue reading

Set custom value in repeating field

add_filter(‘frm_validate_field_entry’, ‘set_custom_repeating_val’, 10, 4); function set_custom_repeating_val($errors, $posted_field, $posted_value, $args){ if ( $posted_field->id == 508 ) { $field_to_change = 11700; if ( ! isset( $_POST[‘item_meta’][ $posted_field->id ] ) ) { return $errors; } foreach ( $_POST[‘item_meta’][ $posted_field->id ] as $row_num =>…Continue reading

Limit each user to one entry per option

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 field to validate global $wpdb, $user_ID; $entry_id = (isset($_POST[‘id’])) ? $_POST[‘id’] : 0; $entries = $wpdb->get_col($wpdb->prepare(“SELECT item_id FROM “. $wpdb->prefix…Continue reading

Limit the combination of two fields

add_filter(‘frm_validate_field_entry’, ‘two_fields_unique’, 10, 2); function two_fields_unique( $errors, $posted_field ) { $first_field_id = 125; // change 125 to the id of the first field $second_field_id = 126; // change 126 to the id of the second field if ( $posted_field->id ==…Continue reading

Calculate total time

add_filter(‘frm_validate_field_entry’, ‘calculate_time’, 11, 3); function calculate_time($errors, $field, $value){ if($field->id == 25){ //change 25 to the ID of the hidden or admin only field which will hold the calculation $start = strtotime($_POST[‘item_meta’][23]); //change 23 to the ID of the first field…Continue reading

Require a minimum/maximum word count

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 && $posted_value != ” ){ //change 25 to the ID of the field to validate //check the $posted_value here $words = explode(‘ ‘, $posted_value); //separate at each…Continue reading

Clear Javascript

add_filter(‘frm_validate_field_entry’, ‘my_custom_validation’, 10, 2); function my_custom_validation($errors, $posted_field){ if(!current_user_can(‘administrator’)){ //don’t strip javascript submitted by administrators if(!is_array($_POST[‘item_meta’][$posted_field->id])){ $_POST[‘item_meta’][$posted_field->id] = wp_kses_post($_POST[‘item_meta’][$posted_field->id]); }else{ foreach($_POST[‘item_meta’][$posted_field->id] as $k => $v){ if(!is_array($v)) $_POST[‘item_meta’][$posted_field->id][$k] = wp_kses_post($v); } } } return $errors; }Continue reading

Require minimum age

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 //check the $posted_value here if(strtotime(“-18 years“) < strtotime($posted_value)){ //if birthday is less than 18 years ago //if it doesn’t…Continue reading

Capitalize all text fields

add_filter(‘frm_validate_field_entry’, ‘field_caps_validation’, 8, 3); function field_caps_validation($errors, $posted_field, $posted_value){ if($posted_field->type == ‘text’){ $_POST[‘item_meta’][$posted_field->id] = mb_strtoupper($posted_value); } return $errors; }Continue reading

Force field value back to previous

add_filter(‘frm_validate_field_entry’, ‘my_custom_validation’, 10, 3); function my_custom_validation($errors, $posted_field, $posted_value){ $featured_field = 25; //change 25 to the ID of the featured field if ( ! current_user_can(‘administrator’) && $posted_field->id == $featured_field ) { if ( isset( $_POST[‘id’] ) && $_POST[‘id’] ) { $force_val…Continue reading