Created
June 13, 2025 14:05
-
-
Save harslannet/0dfd473ec12d1946ce58f79493617a94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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