filter em_booking_add doesn't work
-
In my functions.php I have an add_filter(’em_booking_add’,….. that well worked.
With last upgrade it doesn’t work anymore.
Any suggestions?
thank’s
Stefania
-
Hi Stefania,
Can you post the code you’re using?
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
function em_validate($result, $EM_Booking){ global $pc_users; if(($data = pc_user_logged('id')) == false) { if ($_REQUEST['user_name'] == ''){ $EM_Booking->add_error('Il nome e obbligatorio'); $result = false; } if ($_REQUEST['user_last_name'] == ''){ $EM_Booking->add_error('Il cognome e obbligatorio'); $result = false; } if ($_REQUEST['dbem_phone'] == ''){ $EM_Booking->add_error('Il numero di telefono è obbligatorio'); $result = false; } if ($_REQUEST['user_email'] == ''){ $EM_Booking->add_error("L'indirizzo e-mail obbligatorio"); $result = false; } //test se la mail è presente tra gli utenti di private content //errore devi loggarti $args = array( 'search' => array( array('key' => 'email', 'operator' => '=', 'val' => $_REQUEST['user_email']) ) ); $utente = $pc_users->get_users($args); if(!empty($utente)) { $EM_Booking->add_error("L'indirizzo e-mail è associato ad un utente registrato. Effettuare il login e riprovare la prenotazione"); $result = false; } } return $result; } add_filter('em_booking_validate','em_validate', 1, 2); function bweb_save_custom_event_fields (){ global $EM_Booking ; if( ! empty( $_REQUEST['user_last_name'] ) ){ $EM_Booking->booking_meta['registration']['user_last_name'] = wp_kses( $_REQUEST['user_last_name'], array() ); } if( ! empty( $_REQUEST['user_indirizzo'] ) ){ $EM_Booking->booking_meta['registration']['user_indirizzo'] = wp_kses( $_REQUEST['user_indirizzo'], array() ); } } add_filter('em_booking_add','bweb_save_custom_event_fields'); function bweb_table_custom_event_fields($template, $EM_Bookings_Table){ $template['user_last_name'] = __('Cognome', 'textdomain'); $template['user_indirizzo'] = __('Indirizzo', '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_last_name' ){ $val = $EM_Booking->get_person()->user_last_name; } if( $col == 'user_indirizzo' ){ $val = $EM_Booking->get_person()->user_indirizzo; } return $val; } add_filter('em_bookings_table_rows_col','bweb_display_col_custom_event_fields', 10, 5);I posted all the functions 🙂
Thank’s!
(Sorry for errors I’m posting from mobile)What output / checking does this code give?
The first one checks some required fields.
The others add 2 fields in registration forms e save in DB
It worked well before last updateWhat’s happening now? Are you seeing any error messages?
Simply in the booking form there aren’t the custom fields hooked.
The validation works because it returns the message about required fields. Differently em_booking_add doesn’t add fieldsDo you have any other code running that might interfere with this code?
If you test with all other plugins deactivated and while running the default WordPress theme, does it work?
Ok, I resolved,
I accidentally deleted the code and the function to add fields in the booking-form add_filter(’em_register_form’,’foo’,20);Now the question is:
Is there a way to order the field in the registration form putting my new fields before the standard ones?
Or the only solution is to edit the booking-fields.php file?
Thanks for your patience 🙂
The topic ‘filter em_booking_add doesn't work’ is closed to new replies.