Add coupon codes

add_filter(‘frm_add_entry_meta’, ‘apply_my_coupon’); function apply_my_coupon($values){ if($values[‘field_id’] == 25){ //change 25 to the ID of the price field $coupon_field = 26; //change 26 to the ID of the coupon code field $discount_field = 30; //Change 30 to the ID of the discount…Continue reading

Send submitted entry to another site

add_action(‘frm_after_create_entry’, ‘yourfunctionname’, 30, 2); function yourfunctionname($entry_id, $form_id){ if($form_id == 5){ //replace 5 with the id of the form $args = array(); if(isset($_POST[‘item_meta’][30])) //replace 30 and 31 with the appropriate field IDs from your form $args[‘data1‘] = $_POST[‘item_meta’][30]; //change ‘data1’ to…Continue reading

Create a new WordPress Category

add_action(‘frm_after_create_entry’, ‘after_entry_created’, 30, 2); function after_entry_created($entry_id, $form_id){ if($form_id == 5){ //change 5 to the ID of your form if(isset($_POST[‘item_meta’][25])){ //change 25 to the ID of the field used to add a category $category_name = ‘category’; //if you’re using a custom…Continue reading

Validate field in repeating section

add_filter(‘frm_validate_field_entry’, ‘my_custom_validation’, 10, 4); function my_custom_validation($errors, $posted_field, $posted_value, $args){ if($posted_field->id == 102){ //change to the ID of the field to validate if(!in_array($posted_value, array(123456,987654,234567))){ //enter your allowed values //if it doesn’t match up, add an error: $errors[‘field’. $args[‘id’]] = ‘Not a…Continue reading

Redirect User if Already Registered

add_filter(‘frm_validate_field_entry’, ‘maybe_redirect’, 10, 3); function maybe_redirect( $errors ){ if ( isset( $errors[‘field’. 799 ]) && $errors[‘field’. 799 ] == ‘This email address is already registered.’ ) { //change 799 to your email field id wp_redirect(‘http://www.google.com‘); //change the url to the…Continue reading

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