Cancel button
-
Hi,
I needed similar functionality for my site to the #_BOOKINGBUTTON but that can trigger actions, as our users are all logged in I’ve created the below shortcode. The code works but I thought I’d post it here to see if it could be improved or in the hope it may be useful for others.
add_shortcode('CANCELBUTTON', 'em_cancel_button_shortcode'); function em_cancel_button_shortcode(){ global $post; // Get the current User $EM_Person = new EM_Person( get_current_user_id() ); // Get the bookings for user $EM_Bookings = $EM_Person->get_bookings(); // Nonce used for security on links $nonce = wp_create_nonce('booking_cancel'); $cancel_link =''; $EM_Event = em_get_event($post, 'post_id'); foreach ($EM_Bookings as $EM_Booking) { $EM_Booking_Event = $EM_Booking->get_event(); if ($EM_Booking_Event->ID == $EM_Event->ID){ if( !in_array($EM_Booking->booking_status, array(2,3)) && get_option('dbem_bookings_user_cancellation') && $EM_Event->get_bookings()->has_open_time() ){ $cancel_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'booking_cancel', 'booking_id'=>$EM_Booking->booking_id, '_wpnonce'=>$nonce)); $cancel_link = '<a class="em-cancel-btn" href="'.$cancel_url.'" onclick="if( !confirm(EM.booking_warning_cancel) ){ return false; }">'.__('Cancel','events-manager').'</a>'; } } } return $cancel_link; }
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Cancel button’ is closed to new replies.