Disable gateways for specific events

Sep 5th, 2017
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. This snippet disables the paypal gateway for events with event ID 123 and 321. You can modify the events to exclude and gateways to exclude in $events_to_exclude and $gateways_to_exclude respectively.
  5. This only works if your booking forms are showing on the specific event page, rather than via a shortcode or similar on another page.
  7. For information on implementing this snippet see this -
  8. */
  9. function my_emp_disable_gateway($return){
  10.     global $EM_Event;
  11.     $events_to_exclude = array(123,321); //event ids you want excluding the following gateways
  12.     $gateways_to_exclude = array('paypal'); //gateways you want excluded for the events above
  13.     if( in_array($EM_Event->event_id, $events_to_exclude) ){
  14.         foreach($gateways_to_exclude as $gateway){ //loop through active gateways
  15.             unset($return[$gateway]); //removes gateway from the active gateways array
  16.         }
  17.     }
  18.     return $return;
  19. }
  20. add_filter('option_em_payment_gateways','my_emp_disable_gateway', 10, 1);
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add to your ad blocker whitelist or disable your adblocking software.