Dynamically add Order ID and save entry data with Order

add_action( ‘woocommerce_new_order_item’, ‘save_entry_data_with_order’, 10, 3 ); function save_entry_data_with_order( $item_id, $cart_item, $order_id ) { // check if there’s form data to process if ( empty( $cart_item->legacy_values[‘_formidable_form_data’] ) ) { return; } // get form entry $entry = FrmEntry::getOne( $cart_item->legacy_values[‘_formidable_form_data’] ); if…Continue reading

Change field value after completed order

add_action( ‘woocommerce_order_status_completed’, ‘update_frm_entry_after_wc_order_completed’ ); function update_frm_entry_after_wc_order_completed( $order_id ) { $order = new WC_Order( $order_id ); $items = $order->get_items(); foreach ( $items as $item_id => $product ) { if ( isset( $product[‘formidable_form_data’] ) && is_numeric( $product[‘formidable_form_data’] ) ) { $entry_id =…Continue reading

Exclude an entry

add_filter( ‘frm_entries_list_query’, ‘set_listed_entries’, 10,2 ); function set_listed_entries( $where, $atts ) { $form_id = 2; // set to your form id if ( $atts[‘form_id’] == $form_id && ! current_user_can(‘administrator’) ) { // who should not see the form? $where[‘it.id !’] =…Continue reading

Use a custom class for the success message

add_filter( ‘frm_main_feedback’, ‘frm_custom_feedback_class’, 20, 3 ); function frm_custom_feedback_class( $message, $form, $entry_id ) { if ( $form->id == 125 ) { //Replace with the ID of your form $message = str_replace(‘frm_message’, ‘my_custom_class’, $message ); } return $message; }Continue reading

Show a message when trying to edit

add_action(‘frm_display_form_action’, ‘close_my_form’, 20, 3); function redirect_edit_form( $params, $fields, $form ) { global $frm_vars; $edit_attempt = isset( $_GET[‘entry’] ); $editing_entry = isset( $frm_vars[‘editing_entry’] ) ? $frm_vars[‘editing_entry’] : 0; if ( $edit_attempt && ! $editing_entry ) { echo ‘You do not have…Continue reading

Populate a field with categories

add_filter(‘frm_setup_new_fields_vars’, ‘frm_populate_categories’, 20, 2); add_filter(‘frm_setup_edit_fields_vars’, ‘frm_populate_categories’, 20, 2); function frm_populate_categories( $values, $field ) { if ( $field->id == 125 ) { //replace 125 with the ID of the field to populate // Adjust your category aruments as needed $category_args =…Continue reading

Auto populate multiple rows in a repeater

add_filter(‘frm_setup_new_fields_vars’, ‘frm_auto_populate_repeating_fields’, 20, 2); function frm_auto_populate_repeating_fields( $values, $field ) { if ( $field->id == 24094 ) {//Replace with the ID of your field if ( ! isset( $_POST[‘item_meta’][ $field->id ] ) ) { $first_field = 123; $second_field = 124; $values[…Continue reading

Set the minimum date for second repeating date field

add_action(‘frm_date_field_js’, ‘start_and_end_dates_repeating’, 10, 2); function start_and_end_dates_repeating($field_id, $options){ $days_between = 0;// Change 0 to the number of days that should be between the start and end dates $field_one = ‘field_pickup‘;// Change pickup to the KEY of the first date field $field_two…Continue reading

Move description

add_filter(‘frm_custom_html’, ‘frm_move_field_description’, 20, 2); function frm_move_field_description( $default_html, $field_type ) { $start_description = ‘[if description]’; $end_description = ‘[/if description]’; $description_start_pos = strpos( $default_html, $start_description ); $description_end_pos = strpos( $default_html, $end_description ); if ( $description_start_pos === false || $description_end_pos === false )…Continue reading