Title: Cancel button
Last modified: October 7, 2020

---

# Cancel button

 *  Resolved [iamthewebb](https://wordpress.org/support/users/iamthewebb/)
 * (@iamthewebb)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/cancel-button-2/)
 * 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)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/cancel-button-2/#post-13512113)
 * Hi,
 * Thank you for sharing, this will surely help others as well.

Viewing 1 replies (of 1 total)

The topic ‘Cancel button’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/cancel-button-2/#post-13512113)
 * Status: resolved