xpay✦ Commerce
Directory
WooCommerce plugins
Coupons Role Restriction for WooCommerce
Coupons Role Restriction for WooCommerce
Restrict the usage of WooCommerce coupons based on user roles.
Will this break my store?
What the WordPress.org registry says about keeping Coupons Role Restriction for WooCommerce running.
Tested to 6.9.5 — 1 branch behind 7.0
Tested against the WordPress branch in use today.7 months ago
At least 3.4 releases a year since launch. WordPress.org only lists versions still available for download, so the real number may be higher.7.4
Your host must be running at least this version.6.4
woocommerce
These must be installed and active first.1
A single maintainer. Worth knowing if the plugin is load-bearing for your store.Maintenance & trust
Scored on how Coupons Role Restriction for WooCommerce is looked after — not on how many stores run it.
Maintenance
26 / 35WordPress compatibility
14 / 20Support responsiveness
Not enough dataMerchant satisfaction
Not enough dataListing transparency
7 / 10Ratings
No one has rated this plugin on WordPress.org yet. That is a statement about the ratings page, not about the plugin — plenty of well-kept plugins never collect them.
This plugin allows you to restrict the usage of WooCommerce coupons based on user roles, including guest users.
You can specify which roles (including guests) are allowed or excluded from using a coupon, providing more control over your discount strategies.
Features
- Restrict coupon usage based on user roles.
- Option to specify both allowed and excluded roles.
- Support for guest users with a “Customer Is A Guest” pseudo-role.
- Customize the error message via a filter.
Filters
runthings_wc_coupons_role_restrict_error_message
This filter allows customization of the error message shown when a coupon is not valid for the user’s account type.
For detailed documentation and advanced examples, see the full documentation on GitHub.
Parameters:
$message(string): The default error message, e.g.,"Sorry, this coupon is not valid for your account type.".$context(array): Additional context for the error, including the coupon, user roles, and guest status.
$context object format:
The $context array contains the following keys:
– coupon (WC_Coupon): The coupon object being validated.
– is_guest (bool): Whether the current user is a guest (not logged in).
– user (WP_User): The current user object. For guests, this will be an empty user object.
– allowed_roles (array): Roles explicitly allowed to use the coupon, in the format [role_id => role_name].
– excluded_roles (array): Roles explicitly excluded from using the coupon, in the format [role_id => role_name].
– effective_allowed_roles (array): The final calculated roles allowed to use the coupon, after considering exclusions, in the format [role_id => role_name]. This is the set of roles that can use the coupon.
License
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/gpl-3.0.html.
Icon – Discount by Gregor Cresnar, from Noun Project, https://thenounproject.com/browse/icons/term/discount/ (CC BY 3.0)
Icon – restriction by Puspito, from Noun Project, https://thenounproject.com/browse/icons/term/restriction/ (CC BY 3.0)
This plugin was created to provide a more secure option for restricting coupon usage.
The default email usage restriction for coupons in WooCommerce is based on the unverified billing email address field, which can be freely set by users.
By using role restrictions, you can ensure that only verified and authorized users in specific roles—or guests, when appropriate—can use certain coupons, making it a secure option.
My personal motivation was to have 100% discount coupons that could be used only be staff or developers, without the possibility of this being exploited by somebody putting a fake staff email into the billing email address field.
Edit the coupon and go to the “Usage restriction” tab.
In the “Roles” section, select the roles allowed to use the coupon.
If you want to exclude specific roles, select them in the “Excluded roles” section. For guest users, select or exclude the “Customer Is A Guest” pseudo-role.
If a role is both allowed and excluded, the exclusion will take precedence, and users with that role will not be able to use the coupon.
To restrict a coupon to guests only, select the “Customer Is A Guest” pseudo-role in the “Roles” section and leave all other roles unselected.
Yes, this plugin works alongside other WooCommerce coupon restrictions such as minimum spend, maximum spend, and product restrictions.
Categories
Plugin details
Tags on WordPress.org
