Event manager add a custom field
-
Hi to everyone,
i want to add a custom field on the event manager plugins
i’ve read about to use some code on the functions.php file
i’ve put this code inside, it appears on my register form but it don’t save on the database the selected value.
function bweb_add_custom_event_fields(){
?>
<p>
<label for=’user_company’><?php esc_html_e(‘Company’, ‘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’] = array(‘website’ => $_REQUEST[‘user_company’]);
}
}
add_filter(’em_booking_add’,’bweb_save_custom_event_fields’);function bweb_table_custom_event_fields($template, $EM_Bookings_Table){
$template[‘user_company’] = __(‘Company’, ‘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);Can someone help me please
The topic ‘Event manager add a custom field’ is closed to new replies.