Calculate final date

add_filter(‘frm_validate_field_entry’, ‘set_my_expiration_date’, 10, 3); function set_my_expiration_date($errors, $posted_field, $posted_value){ if ( $posted_field->id == 25 ) { //change 25 to the ID of the date field to change // Get the first date in a UNIX timestamp $first_date = date_create_from_format( ‘d/m/Y‘, $_POST[‘item_meta’][20]…Continue reading

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

Remove all errors

add_filter(‘frm_validate_entry’, ‘validate_my_form’, 20, 2); function validate_my_form($errors, $values){ if ( $values[‘form_id’] == 45 && $_POST[‘item_meta’][125] != ‘Yes‘ ) { //Change 45 to the ID of your form, 125 to the ID of a field, and ‘Yes’ to any value return array();…Continue reading

Basic format

add_filter(‘frm_validate_entry’, ‘validate_my_form’, 20, 2); function validate_my_form($errors, $values){ if($values[‘form_id’] == 45){//Change 45 to the ID of your form and add additional conditions here $errors[‘my_error’] = ‘You are not allowed to submit this form.‘;//Change this to your error } return $errors; }Continue reading

Customize the spam message

add_filter(‘frm_validate_entry’, ‘validate_my_form’, 20, 2); function validate_my_form($errors, $values){ if ( isset($errors[‘spam’]) ) { $errors[‘spam’] = ‘No submissions for you!‘; } return $errors; }Continue reading

Require one field from a set

add_filter(‘frm_validate_entry’, ‘check_phone_fields’, 10, 2); function check_phone_fields( $errors, $values ) { if ( $values[‘form_id’] == 45 ) { // change 45 to your form id $group_fields = array(25, 26, 27); // change 25, 26, 27 to the ids of your fields…Continue reading

Prevent submissions from an IP

add_filter(‘frm_validate_entry’, ‘frm_check_ip_blacklist’, 10, 2); function frm_check_ip_blacklist( $errors, $values ) { $ips = array( ‘107.150.42.226‘, ‘195.154.232.138‘, ‘155.108.70.195‘ ); $current_ip = FrmAppHelper::get_ip_address(); if ( in_array( $current_ip, $ips ) ) { $errors[‘spam’] = ‘You are not allowed to do that’; } return $errors;…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