Multi custom fields for venues
-
Hello,
I have a question about custom fields for venues.
I follow the guidelines here:
https://wp-event-organiser.com/documentation/developers/venue-meta-data-and-metaboxes/I try to apply it for multi custom fields like that:
/** * Add meta box to venue * @ https://wp-event-organiser.com/documentation/developers/venue-meta-data-and-metaboxes/ * @since Custom **/ add_action('add_meta_boxes','eo_custom_add_metabox'); function eo_custom_add_metabox(){ add_meta_box('eo_custom_metabox','Informations complémentaires', 'eo_custom_metabox_callback', 'event_page_venues', 'side', 'high'); } function eo_custom_metabox_callback( $venue ){ //Metabox's innards: $time = eo_get_venue_meta($venue->term_id, '_opening_times',true); $venue_phone = eo_get_venue_meta($venue->term_id, '_venue_phone',true); //Remember to use nonces! wp_nonce_field('eo_custom_venue_meta_save', 'eo_custom_plugin_nonce_field' ); ?> <label> Opening times:</label> <input type="text" name="eo_custom_opening_time" value="<?php echo esc_attr($time);?>" > <label> Téléphone:</label> <i class="howto">avec l'indicatif: +33 pour la France</i> <input type="text" name="eo_custom_venue_phone" value="<?php echo esc_attr($_venue_phone);?>" > <br/> <br/> <?php } add_action ('eventorganiser_save_venue','eo_custom_save_venue_meta'); function eo_custom_save_venue_meta( $venue_id ){ //If our nonce isn't present just silently abort. if( !isset( $_POST['eo_custom_plugin_nonce_field'] ) ) return; //Check permissions $tax = get_taxonomy( 'event-venue'); if ( !current_user_can( $tax->cap->edit_terms ) ) return; //Check nonce check_admin_referer( 'eo_custom_venue_meta_save', 'eo_custom_plugin_nonce_field' ); //Retrieve meta value(s) $value = $_POST['eo_custom_opening_time']; $value1 = $_POST['eo_custom_venue_phone']; //Update venue meta eo_update_venue_meta($venue_id, '_opening_times', $value); eo_update_venue_meta($venue_id, '_venue_phone', $value1); return; }
The first input works well, but my custom doesn’t seem to be saved. I guess it’s a problem with nonce but i don’t understand which one.
Thank you in advance for your help.
jB
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Multi custom fields for venues’ is closed to new replies.