Add image meta

add_action(‘frm_after_create_entry’, ‘add_uploaded_file_alt’, 30, 2); function add_uploaded_file_alt( $entry_id, $form_id ) { if ( $form_id == 5 ) { //replace 5 with the id of the form // Get all uploaded file attachment IDs $media_ids = $_POST[‘item_meta’][519];//Replace 519 with the ID of…Continue reading

Create entry in form with repeating section

add_action(‘frm_after_create_entry’, ‘create_repeating_section_entry’, 30, 2); function create_repeating_section_entry($entry_id, $form_id){ if ( $form_id == 5 ) { //replace 5 with the id of Form A // Format the values for the repeating section $repeating_values = array(); foreach( $_POST[‘item_meta’][6804] as $k => $r )…Continue reading

Delete the entry, leave the post

add_action( ‘frm_after_create_entry’, ‘after_entry_created’, 60, 2 ); function after_entry_created( $entry_id, $form_id ) { global $wpdb; // unlink the post from the entry $unlinked = $wpdb->update( $wpdb->prefix .’frm_items’, array( ‘post_id’ => ” ), array( ‘id’ => $entry_id ) ); if ( $unlinked…Continue reading

Automatically delete files

add_action(‘frm_after_create_entry’, ‘after_entry_created’, 50, 2); //use 50 to make sure this is done very last function after_entry_created($entry_id, $form_id){ if($form_id == 5){ //change 5 to the ID of your form $field_id = 25; //change 25 to the ID of the upload field…Continue reading

Insert form data into second database table

add_action(‘frm_after_create_entry’, ‘copy_into_my_table’, 20, 2); function copy_into_my_table($entry_id, $form_id){ if($form_id == 4){ //change 4 to the form id of the form to copy global $wpdb; $values = array(‘col_name1’ => $_POST[‘item_meta’][25], ‘col_name2’ => $_POST[‘item_meta’][26]); //replace 25 and 26 with the field ids of…Continue reading

Decrease an available count in another form

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 reservations form global $wpdb; $reward_ids = $_POST[‘item_meta’][25]; //change 25 to the ID of your Dynamic dropdown field in your reservations form $seat_count_field =…Continue reading

Populate fields from User ID

add_filter(‘frm_validate_entry’, ‘frm_add_user_name’, 20, 2); function frm_add_user_name( $errors, $values ) { if ( isset( $_POST[‘item_meta’][25] ) ) { //change 25 to the id of the user id field $user = get_userdata( absint( $_POST[‘item_meta’][25] ) ); //change 25 here too $_POST[‘item_meta’][26] =…Continue reading

Change the post parent

add_filter( ‘frm_new_post’, ‘change_my_post_parent’, 10, 2 ); function change_my_post_parent( $post, $args ) { if ( $args[‘form’]->id == 25 ) { //change 25 to the ID of your form $post[‘post_parent’] = 30; //change 30 to the ID of your WP parent page…Continue reading

Use two fields for the title

add_filter( ‘frm_new_post’, ‘change_my_post_title’, 10, 2 ); function change_my_post_title( $post, $args ) { if ( $args[‘form’]->id == 25 ) { //change 25 to the ID of your form $title = $_POST[‘item_meta’][20] .’ ‘. $_POST[‘item_meta’][21] .’ ‘. $_POST[‘item_meta’][22] .’ ‘. $_POST[‘item_meta’][23]; //change…Continue reading

Create products in EDD

add_filter(‘frm_new_post’, ‘edd_setup_files’, 10, 2); function edd_setup_files($post, $args) { if ( $args[‘form’]->id != 5 ) { //change 5 to the ID of your form return $post; } global $frm_vars; // don’t continue if no files were uploaded if( ! isset( $frm_vars[‘media_id’]…Continue reading