Add Order ID to Entry

add_action( ‘woocommerce_new_order_item’, ‘add_order_id_to_entry’, 10, 3 ); function add_order_id_to_entry( $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

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

Modify field types in order

add_filter( ‘wc_fp_exclude_fields’, ‘frm_adjust_exclude_fields’ ); function frm_adjust_exclude_fields( $exclude ) { $key = array_search( ‘textarea’, $exclude ); if ( $key !== false ) { unset( $exclude[ $key ] ); } return $exclude; }Continue reading

Include or exclude fields in cart

add_filter( ‘wc_fp_include_field_in_cart’, ‘frm_show_field_in_cart’, 10, 3 ); function frm_show_field_in_cart( $display, $field, $value ) { if ( in_array( $field->id, array( ‘123’, ‘345’, ‘456’ ) ) ) { $display = true; } else if ( in_array( $field->id, array( ‘987’, ‘765’, ‘543’ ) )…Continue reading

Black out specific dates

add_filter(‘frm_selectable_dates’, ‘frm_black_out_specific_dates’, 10, 2); function frm_black_out_specific_dates( $selectable, $args ) { if ( $args[‘field’]->field_key == ‘pcm7rl3‘ ) { //replace pcm7rl3 with your field key $selectable = ‘( y+”-“+m+”-“+d != “2017-5-29” && y+”-“+m+”-“+d != “2017-7-4” )’; } return $selectable; }Continue reading

Disable datepicker on mobile

add_filter( ‘frm_field_classes’, ‘frm_remove_date_field_class’, 30, 2 ); function frm_remove_date_field_class( $class, $field ) { if ( $field[‘type’] == ‘date’ && wp_is_mobile() ) { $class = str_replace(‘ frm_date’, ”, $class ); } return $class; }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