New fields using hooks
-
Hi!
I’m trying to add new form fields using hooks/filters. So far I managed to add the field itself, the problem is storing and using the field input. I have been looking at the plugin functions, but don’t really get how I should use $this/$booking.
It would be awesome if you could take a quick look at it and point me in the right direction. I’ll get straight to it, here’s the code so far (just using functions.php at the moment):// ADDING NEW FIELDS: WORKING! add_filter( 'rtb_booking_form_fields', 'buoy_custom_fields', 10, 2 ); function buoy_custom_fields( $fields, $request ) { $fields['reservation']['fields']['retter']['title'] = 'Retter'; $fields['reservation']['fields']['retter']['request_input'] = empty( $request->request_retter ) ? '' : $request->request_retter; $fields['reservation']['fields']['retter']['callback'] = 'rtb_print_form_text_field'; return $fields; } // SAVING VALIDATED DATA: NOT WORKING! add_filter( 'rtb_validate_booking_submission', 'buoy_custom_load', 10, 3 ); function buoy_custom_load( $this, $booking ) { $this->retter = empty( $_POST['rtb-retter'] ) ? '' : sanitize_text_field( stripslashes_deep( $_POST['rtb-retter'] ) ); // I believe I should be adding something to $booking here? return $this; } // SAVING INPUT TO POST METADATA: NOT WORKING add_filter( 'rtb_insert_booking_metadata', 'buoy_insert_meta', 10, 2 ); function buoy_insert_meta( $meta, $this) { $meta['retter'] = $_POST['rtb-retter'] ; // Tried using "$this->booking->retter" etc. - produces error msg return $meta; } // DISPLAY INPUT IN MAIL BY TEMPLATE TAG: TAG IS DISPLAYED, NO INPUT DATA add_filter( 'process_template', 'buoy_template_tags', 10, 2 ); function buoy_template_tags( $template_tags, $notification) { $template_tags['{retter}'] = "test"; return $template_tags; }
https://www.ads-software.com/plugins/restaurant-reservations/
- The topic ‘New fields using hooks’ is closed to new replies.