Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Forked from zackkatz/EDD Admin-Only Test Payments
Created February 21, 2014 05:55
Show Gist options
  • Select an option

  • Save wpsmith/9129496 to your computer and use it in GitHub Desktop.

Select an option

Save wpsmith/9129496 to your computer and use it in GitHub Desktop.
add_filter( 'edd_enabled_payment_gateways', 'kws_edd_enabled_payment_gateways');
/**
* Modify the gateways for users who can manage options so that the Test Payment gateway is activated.
* See /easy-digital-downloads/includes/gateways/functions.php
* @see edd_get_enabled_payment_gateways()
* @param array $gateways Existing activated gateways array
* @return array Modified array
*/
function kws_edd_enabled_payment_gateways($gateway_list) {
global $edd_options,$current_user;
// Is the current user admin?
if(current_user_can( 'manage_options' )) {
$gateway_list['manual'] = array(
'admin_label' => __( 'Test Payment (Admin-Only)', 'edd' ),
'checkout_label' => __( 'Test Payment (Admin-Only)', 'edd' )
);
}
// If the current user's not admin, remove the Test Payment option
else {
unset($gateway_list['manual']);
}
return $gateway_list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment