Block a customer from placing orders in WooCommerce: a plugin you can build today
· 4 min read
WooCommerce has no native way to prevent a specific customer from placing orders. There is no ban button, no block setting, and no place in the admin to mark an account as unwanted. The only built-in option is deleting the account outright, which is permanent and takes the order history with it.
Stores that deal with serial chargebacks, abusive returns, or fraud need something simpler: a checkbox that keeps the account on record while stopping any new orders. The plugin built here adds exactly that. It places a 'Block from ordering' toggle on the user profile page in wp-admin and rejects checkout and add-to-cart for any account where it is checked.
Here is the prompt.
What one build gives you
- Checkbox and block reason field on the user profile admin screen
- Blocked at add-to-cart with a visible notice before reaching checkout
- Blocked at checkout submission before any order is created
- Block is fully reversible without deleting the account or its order history
What it does not do
- Guest checkout: a blocked user can place orders without logging in
- Blocking by email address, IP address, or country
- WooCommerce Subscriptions automatic renewal blocking
- Bulk blocking or importing a list of accounts
- Logging of blocked order attempts or admin notifications when a block triggers
The prompt
Loads into the composer so you can edit it first. Nothing is built, and nothing is charged, until you send it.
Build a WordPress plugin that blocks specific WooCommerce customers from placing orders. Add two fields to the user profile edit screen using the edit_user_profile and show_user_profile actions: a checkbox with the label 'Block from placing orders' and a text input labeled 'Block reason (internal notes only)'. Save both fields as user meta using personal_options_update and edit_user_profile_update. Show the block reason field only to users with the manage_woocommerce capability. In a woocommerce_add_to_cart_validation filter, check whether the current logged-in user has the block meta set to '1', and if so call wc_add_notice() with a plain message saying the account cannot place orders at this time, then return false. In a woocommerce_checkout_process action, repeat the same check and call wc_add_notice() with the same message if blocked. Register all hooks inside a function that fires on the woocommerce_loaded action so the plugin does nothing on sites without WooCommerce active.
Why WooCommerce does not block customers out of the box
WooCommerce inherits WordPress user management, which is built around roles and capabilities. You can remove every role from a user, but that does not prevent them from placing a WooCommerce order. The checkout process does not check roles the way a page-access system would. It checks whether a product is purchasable and whether the cart is valid, not whether the person placing the order has been marked as unwanted.
Deleting the account does stop orders, but it also deletes order history and breaks references to that user in the database. For a store handling a chargeback dispute, losing that history is the last thing you want.
Extensions marketed as WooCommerce user management tools typically focus on analytics: lifetime value, login frequency, last order date. Blocking a specific account from future purchases is a different problem, and the tools that handle analytics do not handle it.
What the plugin does
The plugin adds two fields to the user profile edit screen in wp-admin: a checkbox labeled 'Block from placing orders' and a text input for a block reason. The reason field is stored as user meta and visible only to users with the manage_woocommerce capability, so it works as an internal note without any customer-facing exposure.
When a blocked user attempts to add a product to the cart, a notice appears and the item is not added. If they reach checkout through a cached page or direct URL, the same check fires again on submission and the order is rejected before it is created.
The block is reversible. Unchecking the checkbox and saving the profile removes the restriction immediately.
Who this is for
Stores dealing with chargeback fraud. A buyer who disputes every purchase after delivery creates real costs per transaction. Blocking the account after the second chargeback stops the cycle without erasing the purchase record.
Shops with a serial return problem. A customer who orders, uses, and returns on a loop costs the store money every time. Blocking stops new orders while keeping the history available if a refund dispute lands later.
Any store where a specific account has become a problem and the owner wants a way to stop future orders without deleting the account or managing roles across every part of the site.
Who should use a different approach
If the customer uses guest checkout, this plugin will not stop them. The check is against the logged-in user ID. A guest can place a new order with a different email address and nothing will block it. WooCommerce has a 'Blocked email addresses' field under WooCommerce > Settings > Accounts and Privacy that handles email-level blocking at checkout without a plugin.
If fraud is coming from multiple accounts rather than one, blocking accounts one at a time is the wrong tool. Payment gateway fraud rules or a dedicated fraud detection plugin is a better fit at that scale.
If you need to block by IP address, country, or email domain pattern, this plugin does not cover that. Those require a different approach.
How to build it
Paste the prompt below into Steem. The plugin downloads as a zip and installs under Plugins > Add New > Upload Plugin. Once active, open any user profile under Users > All Users, click Edit, and the 'Block from placing orders' checkbox will appear in the profile section.
A useful follow-up: 'add an admin notice on the user profile page showing the date and time the blocked customer last attempted to place an order' gives visibility into whether the block is being triggered. A second one: 'add a bulk action to the Users admin table to block or unblock multiple accounts at once' is worth adding once you have more than a handful of blocked accounts to manage.
Questions
- Can I block a guest who checked out without an account?
No. The plugin checks the logged-in user ID. A guest using a different email address will not be blocked. WooCommerce has a built-in 'Blocked email addresses' field under WooCommerce > Settings > Accounts and Privacy that can stop specific email addresses at checkout without a plugin.
- What does the blocked customer see?
A plain error notice at the add-to-cart stage, or at checkout if they navigate there directly. The message does not say they are blocked; you can edit the wording in the plugin file.
- Will this stop WooCommerce Subscriptions from renewing?
No. Subscription renewals are processed as scheduled payments, not through the standard checkout flow. The plugin hooks into add-to-cart and checkout submission, neither of which fires on an automatic renewal.
- Can I unblock a customer later?
Yes. Uncheck the 'Block from placing orders' box on their profile and save. The restriction is removed immediately and they can place orders again.
- Does this delete any of the customer's order history?
No. The block is stored as user meta. All existing orders remain intact and the account stays in the database exactly as it was.
The prompt
Loads into the composer so you can edit it first. Nothing is built, and nothing is charged, until you send it.
Build a WordPress plugin that blocks specific WooCommerce customers from placing orders. Add two fields to the user profile edit screen using the edit_user_profile and show_user_profile actions: a checkbox with the label 'Block from placing orders' and a text input labeled 'Block reason (internal notes only)'. Save both fields as user meta using personal_options_update and edit_user_profile_update. Show the block reason field only to users with the manage_woocommerce capability. In a woocommerce_add_to_cart_validation filter, check whether the current logged-in user has the block meta set to '1', and if so call wc_add_notice() with a plain message saying the account cannot place orders at this time, then return false. In a woocommerce_checkout_process action, repeat the same check and call wc_add_notice() with the same message if blocked. Register all hooks inside a function that fires on the woocommerce_loaded action so the plugin does nothing on sites without WooCommerce active.
Steem