Advertisement
eventsmanager

Disable gateways for specific events

Sep 5th, 2017
985
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement