Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    What code are you using to add the Company field to the booking save process?

    Thread Starter PedroDK

    (@pedrodk)

    Hi there,

    I used the coding described in this post:
    https://b-website.com/events-manager-wordpress-add-custom-fields-event-form

    I made sure that the form fields and ids correspond to the letter.

    Thanks.
    P.

    Thread Starter PedroDK

    (@pedrodk)

    … but maybe there is some more coding needed to make the values fall into place in the DB…?

    I don’t know where to put that…

    Can you post your version of the code?

    Which version of Events Manager are you using?

    Thread Starter PedroDK

    (@pedrodk)

    Hi,
    certainly – here it is:

    <?php
    function bweb_add_custom_event_fields(){
    ?>
    <p>
    <label for=’user_company’><?php esc_html_e(‘Firma’, ‘textdomain’); ?></label>
    <input type=”text” name=”user_company” id=”user-company” class=”input” value=”<?php if(!empty($_REQUEST[‘user_company’])) echo esc_attr($_REQUEST[‘user_company’]); ?>” />
    </p>

    <?php
    }
    add_action(’em_register_form’,’bweb_add_custom_event_fields’);

    function bweb_save_custom_event_fields (){
    global $EM_Booking ;
    if( ! empty( $_REQUEST[‘user_company’] ) ){
    $EM_Booking->booking_meta[‘registration’][‘user_company’] = wp_kses( $_REQUEST[‘user_company’], array() );
    }
    }
    add_filter(’em_booking_add’,’bweb_save_custom_event_fields’);

    function bweb_table_custom_event_fields($template, $EM_Bookings_Table){
    $template[‘user_company’] = __(‘Firma’, ‘textdomain’);
    return $template;
    }
    add_action(’em_bookings_table_cols_template’, ‘bweb_table_custom_event_fields’,10,2);

    function bweb_display_col_custom_event_fields($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
    if( $col == ‘user_company’ ){
    $val = $EM_Booking->get_person()->user_company;
    }
    return $val;
    }
    add_filter(’em_bookings_table_rows_col’,’bweb_display_col_custom_event_fields’, 10, 5);

    I am using WordPress 4.4.2 and Events Manager 5.6.2

    Thanks for your help!

    cheers
    P.

    Can you post a link to the live form?

    Thread Starter PedroDK

    (@pedrodk)

    Hi Caimin,

    Unfortunately not – it’s still only implemented on a localhost installation.

    I might be able to later on – it all depends on my client.

    cheers.

    P.

    try to replace the code inside function
    bweb_display_col_custom_event_fields($val, $col, $EM_Booking, $EM_Bookings_Table, $csv) with this:
    if( $col == ‘user_company’ ){
    return $EM_Booking->booking_meta[‘registration’][‘user_company’];
    }

    This works for me. ^.^

    • This reply was modified 8 years, 1 month ago by sasuake.
    • This reply was modified 8 years, 1 month ago by sasuake.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Booking form field’ is closed to new replies.