SHARE
TWEET

Disable gateways for specific events

eventsmanager Sep 5th, 2017 275 Never
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.
  4.  
  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.
  6.  
  7. For information on implementing this snippet see this - http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
  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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top