More advanced example

add_filter(‘frm_redirect_url’, ‘return_page’, 9, 3); function return_page($url, $form, $params){ if($form->id == 5){ //change 5 to the ID of the form to redirect $field_id = 25; //change 25 the the ID of the radio or dropdown field if($_POST[‘item_meta’][$field_id] == ‘A’){ if($_POST[‘item_meta’][26] ==…Continue reading

Change URL when updating

add_filter(‘frm_redirect_url’, ‘return_page’, 9, 3); function return_page($url, $form, $params){ if(!isset($params[‘action’])){ $params[‘action’] = FrmAppHelper::get_param(‘frm_action’); } if($form->id == 5 and $params[‘action’] == ‘update’){ //change 5 to the id of your form $url = ‘http://example.com/redirect-page‘; } return $url; }Continue reading

Allow logged-out users to edit entries

add_filter(‘frm_user_can_edit’, ‘check_user_edit_form’, 10, 2); function check_user_edit_form($edit, $args){ $form_id = is_numeric($args[‘form’]) ? $args[‘form’] : $args[‘form’]->id; if($form_id == 5){ //change 5 to the ID of your form $edit = true; } return $edit; }Continue reading

Prevent editing after a certain date

add_filter(‘frm_user_can_edit’, ‘check_user_edit_entry’, 10, 2); function check_user_edit_entry($edit, $args){ $form_id = is_numeric($args[‘form’]) ? $args[‘form’] : $args[‘form’]->id; if($form_id == 45 and (time() >= strtotime(‘2014-01-31‘))){ //change 45 to the ID of your form and change ‘2014-01-31’ to the form closing date $edit = false;…Continue reading

Change a value in an email

add_filter(‘frm_email_value’, ‘frm_email_val’, 15, 3); function frm_email_val($value, $meta, $entry){ if($meta->field_id == 25){ //change 25 to the ID of your field $value = “My custom email content”; //change the value here } return $value; }Continue reading

Prevent editing after 24 hours

add_filter(‘frm_user_can_edit’, ‘custom_prevent_editing_after_time_limit’, 10, 2); function custom_prevent_editing_after_time_limit($edit, $args){ // If user can normally edit entries from this form, check if entry is within the time limit for editing if ( $edit && $args[‘form’]->id == 19 ) { if ( is_numeric( $args[…Continue reading

Update or create another entry

add_action(‘frm_after_create_entry’, ‘update_or_create_entry’, 30, 2); add_action(‘frm_after_update_entry’, ‘update_or_create_entry’, 10, 2); function update_or_create_entry($entry_id, $form_id){ if ( $form_id == 430 ) {//Change 430 to the ID of Form A global $wpdb; $form2 = ‘480‘;//Change 480 to the ID of Form B //Get user and…Continue reading

Clear a field value after email is sent

add_action(‘frm_after_create_entry’, ‘after_entry_created’, 42, 2); function after_entry_created($entry_id, $form_id){ if ( $form_id == 5 ) { //change 5 to the ID of your form FrmEntryMeta::delete_entry_meta($entry_id, 30); // change 30 to your field id } }Continue reading

Change user role after entry submission

/** * This will change an inactive user to a member after they complete their member profile. */ add_action(‘frm_after_create_entry’, ‘inactive_to_member’, 20, 2); function inactive_to_member($entry_id, $form_id){ if($form_id == 24){ //change 24 to the form id of the form to copy $new_role…Continue reading

Add user meta to user

add_action(‘frm_after_create_entry’, ‘add_entry_id_to_user’, 30, 2); function add_entry_id_to_user( $entry_id, $form_id ) { if($form_id == 24){ //change 24 to the form id of the form to copy $entry = FrmEntry::getOne($entry_id); if ( ! $entry->user_id ) { return; //don’t continue if no user }…Continue reading