Add custom field
-
Hi,
I would like to add a custom field but I can’t get it to show up.
I’ve got this in my functions.php
function custom_guest_details_field( $fields ) {
$fields[ ‘custom_field’ ] = array(
‘label’ => esc_html__( ‘Relatienummer’, ‘hotelier’ ),
‘placeholder’ => esc_html_x( ‘Relatienummer’, ‘placeholder’, ‘hotelier’ ),
‘type’ => ‘text’,
‘required’ => true,
‘class’ => array( ‘form-row-wide’ )
);
return $fields;
}
add_filter( ‘hotelier_booking_default_address_fields’ , ‘custom_guest_details_field’ );function custom_fields_in_reservation_data() {
global $post;
$reservation = htl_get_reservation( $post->ID );
if ( $reservation->guest_custom_field ) : ?>
<p>
<?php esc_html_e( ‘Relatienummer’, ‘text-domain’ ); ?>:
<?php echo esc_html( $reservation->guest_custom_field ); ?>
</p>
<?php endif;
}
add_action( ‘hotelier_reservation_after_guest_details’, ‘custom_fields_in_reservation_data’ );
- The topic ‘Add custom field’ is closed to new replies.