Save custom date format in custom field

add_filter( ‘frm_new_post’, ‘create_a_custom_field’, 10, 2 ); function create_a_custom_field( $post, $args ) { $field_id = 25; // change 25 to the id of the field to draw from if ( isset( $_POST[‘item_meta’][ $field_id ] ) ) { $field_value = sanitize_text_field( $_POST[‘item_meta’][…Continue reading

Save a due date

add_filter(‘frm_add_entry_meta’, ‘change_due_date’); function change_due_date($new_values) { if($new_values[‘field_id’] == 6103 and !is_admin()) { // 776 is the Due Date field on the form – note that this field must have a value in it on form submit or this code will not…Continue reading

Send email after submitting comment

add_filter(‘frm_add_entry_meta’, ‘custom_change_field_value’); function custom_change_field_value($new_values){ if($new_values[‘field_id’] == 0){ //0 indicates this is a comment $subject = ‘New comment‘; //change email subject here $send_to = array(‘[email protected]’, ‘[email protected]‘); //set email addresses here $info = maybe_unserialize($new_values[‘meta_value’]); $message = $info[‘comment’]; foreach($send_to as $to) wp_mail($to, $subject,…Continue reading

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

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

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