Changeset 2806972
- Timestamp:
- 10/29/2022 10:24:39 AM (3 years ago)
- Location:
- block-specific-spam-woo-orders/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
woo-block-spam-orders.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
block-specific-spam-woo-orders/trunk/readme.txt
r2719240 r2806972 3 3 Tags: woocommerce,woo,block,spam,orders 4 4 Requires at least: 5.1 5 Tested up to: 6. 05 Tested up to: 6.1 6 6 Requires PHP: 5.4 7 7 Stable tag: 4.3 … … 25 25 == Changelog == 26 26 27 = 0.6 = 28 * Added a new function to handle checking against multiple blocked domains, now including ["@fakemail"] 29 * Confirming support with WP 6.1 and Latest WooCommerce 30 27 31 = 0.55 = 28 32 * Tested support with WP 6.0 and latest WC - works fine. -
block-specific-spam-woo-orders/trunk/woo-block-spam-orders.php
r2719240 r2806972 6 6 * Description: A quick plugin to block on-going issues with spam WooCommerce orders November 2020 7 7 * Author: guwii 8 * Version: 0. 558 * Version: 0.6 9 9 * Author URI: https://guwii.com 10 10 * License: GPL3+ 11 11 * Text Domain: guwii-woo-block-spam-orders 12 12 * WC requires at least: 4.3 13 * WC tested up to: 6.4.113 * WC tested up to: 7.0 14 14 */ 15 15 … … 19 19 add_action('woocommerce_after_checkout_validation', 'action_woocommerce_validate_spam_checkout', 10, 2); 20 20 21 // Check over a list of provided domains, to see if $user_email matches any of them: 22 function has_a_blocked_domain($user_email) 23 { 24 // Provide our list of domains we want to block: 25 $listOfBlockedDomains = ['abbuzz.com', 'fakemail.com']; 26 // Set the default return of false: 27 $hasABlockedDomain = false; 28 // Compare users email with our list of blocked domains: 29 foreach ($listOfBlockedDomains as $aBlockedDomain) { 30 // If a blocked domain exists in the users email, return true; 31 // Info: 32 // "!== false" is used for comparison, as if the users email matches a blocked domain 33 // the return from [strpos()] is the position of the string (a number), we don't care about that, we just want to know if it was false [i.e not found] 34 if (strpos($user_email, $aBlockedDomain) !== false) { 35 $hasABlockedDomain = true; 36 } 37 } 38 return $hasABlockedDomain; 39 } 21 40 // Check if billing name or email domain is a specific string, if it is we'll decline the order: 22 41 function action_woocommerce_validate_spam_checkout($fields, $errors) 23 42 { 24 43 $customer_name_to_block = 'bbbbb'; 25 $email_domain_to_block = 'abbuzz.com';26 44 if ( 27 45 $fields['billing_first_name'] == $customer_name_to_block 28 46 || 29 strpos(strtolower($fields['billing_email']), $email_domain_to_block)47 (has_a_blocked_domain($fields['billing_email']) == true) 30 48 ) { 31 49 $errors->add('validation', 'Spam.');
Note: See TracChangeset
for help on using the changeset viewer.