Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save harslannet/0dfd473ec12d1946ce58f79493617a94 to your computer and use it in GitHub Desktop.
Save harslannet/0dfd473ec12d1946ce58f79493617a94 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'woocommerce_available_payment_gateways', 'disable_payment_gateway_by_email' );
function disable_payment_gateway_by_email( $available_gateways ) {
// Devre dışı bırakılacak ödeme ağ geçidi ID'si
$gateway_id_to_disable = 'cod'; // 'bacs' (banka havalesi), 'cheque' (çek ödemesi) vb. olabilir.
// Ödeme ağ geçidinin devre dışı bırakılacağı e-posta adresleri listesi
$restricted_emails = array(
'[email protected]',
'[email protected]',
'[email protected]',
// Buraya devre dışı bırakmak istediğiniz diğer e-posta adreslerini ekleyin
);
// Eğer ödeme ağ geçidi mevcutsa devam et
if ( isset( $available_gateways[ $gateway_id_to_disable ] ) ) {
// Şu anki giriş yapmış kullanıcının e-postasını al
$current_user = wp_get_current_user();
$user_email = $current_user->user_email;
// Kullanıcının e-postası kısıtlı e-posta listesinde mi kontrol et
if ( in_array( $user_email, $restricted_emails ) ) {
unset( $available_gateways[ $gateway_id_to_disable ] );
}
}
return $available_gateways;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment