• 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’ );

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter schnolly

    (@schnolly)

    Thanks in advance for your answer! Pip

    Plugin Author benitolopez

    (@benitolopez)

    Please paste the code here so I can see it correctly:
    https://pastebin.com/

    • This reply was modified 6 years, 5 months ago by benitolopez.
    Thread Starter schnolly

    (@schnolly)

    Thanks for your reply:

    https://pastebin.com/VYTjjwuT

    Plugin Author benitolopez

    (@benitolopez)

    Hi,

    Tried right now your code and it works correctly.

    Where did you paste that code? You need to put it in the functions.php file of your theme or child theme. Can you share (with pastebin) the complete code of your functions.php file?

    PS. Be sure that you’re using the last version of Easy WP Hotelier. And try the code with the default WP theme (Twenty Seventeen) or with the Manila theme.

    Best Regards

    Thread Starter schnolly

    (@schnolly)

    Hi Benito,

    I see what you mean now, I can see the custom field on the page “bookings”. When I fill it out I also see the output on the registration list.
    But what I would like is to see it when I click on Add Reservation from the Dashboard and when I edit a reservation from the Dashboard. Is that possible?
    Could you give me directions on how to accomplish this?

    Thanks! Pip

    Plugin Author benitolopez

    (@benitolopez)

    There is a filter available for the guest details only. If is that what you’re looking for you can use that filter:

    hotelier_admin_guest_details_fields

    Add also this code to your functions.php file. This will show the new filed at the end of the form:
    https://pastebin.com/raw/kUkj6pNY

    Best Regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add custom field’ is closed to new replies.