{"id":199415,"date":"2024-07-15T14:44:01","date_gmt":"2024-07-15T14:44:01","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/coupons-role-restriction-for-woocommerce\/"},"modified":"2026-01-07T01:30:24","modified_gmt":"2026-01-07T01:30:24","slug":"runthings-wc-coupons-role-restrict","status":"publish","type":"plugin","link":"https:\/\/tuk.wordpress.org\/plugins\/runthings-wc-coupons-role-restrict\/","author":20973379,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.1.3","stable_tag":"1.1.3","tested":"6.9.4","requires":"6.4","requires_php":"7.4","requires_plugins":null,"header_name":"Coupons Role Restriction for WooCommerce","header_author":"runthingsdev","header_description":"Restrict the usage of coupons based on user roles.","assets_banners_color":"c0dade","last_updated":"2026-01-07 01:30:24","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/runthings.dev\/wordpress-plugins\/wc-coupons-role-restrict\/","header_author_uri":"https:\/\/runthings.dev\/","rating":0,"author_block_rating":0,"active_installs":60,"downloads":1890,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"runthingsdev","date":"2024-07-15 14:43:52"},"1.0.1":{"tag":"1.0.1","author":"runthingsdev","date":"2024-08-14 12:06:26"},"1.1.0":{"tag":"1.1.0","author":"runthingsdev","date":"2024-11-17 03:09:23"},"1.1.1":{"tag":"1.1.1","author":"runthingsdev","date":"2025-06-24 21:13:36"},"1.1.2":{"tag":"1.1.2","author":"runthingsdev","date":"2025-12-17 13:40:49"},"1.1.3":{"tag":"1.1.3","author":"runthingsdev","date":"2026-01-07 01:30:24"}},"upgrade_notice":{"1.1.3":"<p>Fixed missing &quot;And&quot; separator in the coupon usage restriction panel to match WooCommerce core styling.<\/p>","1.1.2":"<p>Bump tested up to 6.9.<\/p>","1.1.1":"<p>Bump WordPress tested up to field to support 6.8 branch.<\/p>"},"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3433980,"resolution":"128x128","location":"assets","locale":"","width":128,"height":128},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3433980,"resolution":"256x256","location":"assets","locale":"","width":256,"height":256}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3433980,"resolution":"1544x500","location":"assets","locale":"","width":1544,"height":500},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3433980,"resolution":"772x250","location":"assets","locale":"","width":772,"height":250}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.1.0","1.1.1","1.1.2","1.1.3"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3433980,"resolution":"1","location":"assets","locale":"","width":1255,"height":728},"screenshot-2.png":{"filename":"screenshot-2.png","revision":3433980,"resolution":"2","location":"assets","locale":"","width":608,"height":319},"screenshot-3.png":{"filename":"screenshot-3.png","revision":3433980,"resolution":"3","location":"assets","locale":"","width":447,"height":243}},"screenshots":{"1":"Coupon settings page with role restriction fields.","2":"Coupon role selection field.","3":"Example denied coupon usage due to invalid role."}},"plugin_section":[],"plugin_tags":[591,331,229632,11917,286],"plugin_category":[45],"plugin_contributors":[228895],"plugin_business_model":[],"class_list":["post-199415","plugin","type-plugin","status-publish","hentry","plugin_tags-coupons","plugin_tags-discount","plugin_tags-role-restriction","plugin_tags-user-roles","plugin_tags-woocommerce","plugin_category-ecommerce","plugin_contributors-runthingsdev","plugin_committers-runthingsdev","plugin_support_reps-rtpharry"],"banners":{"banner":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/banner-772x250.png?rev=3433980","banner_2x":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/banner-1544x500.png?rev=3433980","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/icon-128x128.png?rev=3433980","icon_2x":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/icon-256x256.png?rev=3433980","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/screenshot-1.png?rev=3433980","caption":"Coupon settings page with role restriction fields."},{"src":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/screenshot-2.png?rev=3433980","caption":"Coupon role selection field."},{"src":"https:\/\/ps.w.org\/runthings-wc-coupons-role-restrict\/assets\/screenshot-3.png?rev=3433980","caption":"Example denied coupon usage due to invalid role."}],"raw_content":"<!--section=description-->\n<p>This plugin allows you to restrict the usage of WooCommerce coupons based on user roles, including guest users.<\/p>\n\n<p>You can specify which roles (including guests) are allowed or excluded from using a coupon, providing more control over your discount strategies.<\/p>\n\n<h4>Features<\/h4>\n\n<ul>\n<li>Restrict coupon usage based on user roles.<\/li>\n<li>Option to specify both allowed and excluded roles.<\/li>\n<li>Support for guest users with a \"Customer Is A Guest\" pseudo-role.<\/li>\n<li>Customize the error message via a filter.<\/li>\n<\/ul>\n\n<h3>Filters<\/h3>\n\n<h4>runthings_wc_coupons_role_restrict_error_message<\/h4>\n\n<p>This filter allows customization of the error message shown when a coupon is not valid for the user's account type.<\/p>\n\n<p>For detailed documentation and advanced examples, see the <a href=\"https:\/\/github.com\/runthings-dev\/runthings-wc-coupons-role-restrict#filters\">full documentation on GitHub<\/a>.<\/p>\n\nParameters:\n\n<ol>\n<li><strong><code>$message<\/code><\/strong> (<code>string<\/code>): The default error message, e.g., <code>\"Sorry, this coupon is not valid for your account type.\"<\/code>.<\/li>\n<li><strong><code>$context<\/code><\/strong> (<code>array<\/code>): Additional context for the error, including the coupon, user roles, and guest status.<\/li>\n<\/ol>\n\n<code>$context<\/code> object format:\n\n<p>The <code>$context<\/code> array contains the following keys:\n- <strong><code>coupon<\/code><\/strong> (<code>WC_Coupon<\/code>): The coupon object being validated.\n- <strong><code>is_guest<\/code><\/strong> (<code>bool<\/code>): Whether the current user is a guest (not logged in).\n- <strong><code>user<\/code><\/strong> (<code>WP_User<\/code>): The current user object. For guests, this will be an empty user object.\n- <strong><code>allowed_roles<\/code><\/strong> (<code>array<\/code>): Roles explicitly allowed to use the coupon, in the format <code>[role_id =&gt; role_name]<\/code>.\n- <strong><code>excluded_roles<\/code><\/strong> (<code>array<\/code>): Roles explicitly excluded from using the coupon, in the format <code>[role_id =&gt; role_name]<\/code>.\n- <strong><code>effective_allowed_roles<\/code><\/strong> (<code>array<\/code>): The final calculated roles allowed to use the coupon, after considering exclusions, in the format <code>[role_id =&gt; role_name]<\/code>. This is the set of roles that can use the coupon.<\/p>\n\n<h3>License<\/h3>\n\n<p>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.<\/p>\n\n<p>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.<\/p>\n\n<p>You should have received a copy of the GNU General Public License along with this program; if not, see <a href=\"http:\/\/www.gnu.org\/licenses\/gpl-3.0.html\">http:\/\/www.gnu.org\/licenses\/gpl-3.0.html<\/a>.<\/p>\n\n<p>Icon - Discount by Gregor Cresnar, from Noun Project, https:\/\/thenounproject.com\/browse\/icons\/term\/discount\/ (CC BY 3.0)<\/p>\n\n<p>Icon - restriction by Puspito, from Noun Project, https:\/\/thenounproject.com\/browse\/icons\/term\/restriction\/ (CC BY 3.0)<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the plugin files to the <code>\/wp-content\/plugins\/runthings-wc-coupons-role-restrict<\/code> directory, or install the plugin through the WordPress plugins screen directly.<\/li>\n<li>Activate the plugin through the 'Plugins' screen in WordPress.<\/li>\n<li>Go to WooCommerce area of the admin panel, and look under Marketing &gt; Coupons and edit or create a coupon.<\/li>\n<li>In the \"Usage restriction\" tab, you will see the options to select allowed and excluded roles for the coupon, including the \"Customer Is A Guest\" pseudo-role.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='why%20was%20this%20plugin%20created%3F'><h3>Why was this plugin created?<\/h3><\/dt>\n<dd><p>This plugin was created to provide a more secure option for restricting coupon usage.<\/p>\n\n<p>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.<\/p>\n\n<p>By using role restrictions, you can ensure that only verified and authorized users in specific roles\u2014or guests, when appropriate\u2014can use certain coupons, making it a secure option.<\/p>\n\n<p>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.<\/p><\/dd>\n<dt id='how%20do%20i%20restrict%20a%20coupon%20to%20specific%20roles%3F'><h3>How do I restrict a coupon to specific roles?<\/h3><\/dt>\n<dd><p>Edit the coupon and go to the \"Usage restriction\" tab.<\/p>\n\n<p>In the \"Roles\" section, select the roles allowed to use the coupon.<\/p>\n\n<p>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.<\/p><\/dd>\n<dt id='what%20happens%20if%20a%20role%20is%20both%20allowed%20and%20excluded%3F'><h3>What happens if a role is both allowed and excluded?<\/h3><\/dt>\n<dd><p>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.<\/p><\/dd>\n<dt id='how%20do%20i%20allow%20a%20coupon%20for%20guests%20only%3F'><h3>How do I allow a coupon for guests only?<\/h3><\/dt>\n<dd><p>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.<\/p><\/dd>\n<dt id='can%20i%20use%20this%20plugin%20with%20other%20woocommerce%20coupon%20restrictions%3F'><h3>Can I use this plugin with other WooCommerce coupon restrictions?<\/h3><\/dt>\n<dd><p>Yes, this plugin works alongside other WooCommerce coupon restrictions such as minimum spend, maximum spend, and product restrictions.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.1.3 - 6th January 2026<\/h4>\n\n<ul>\n<li>Fixed missing \"And\" separator in the coupon usage restriction panel to match WooCommerce core styling.<\/li>\n<li>Move plugin directory assets to .wordpress-org\/ folder.<\/li>\n<\/ul>\n\n<h4>1.1.2 - 17th December 2024<\/h4>\n\n<ul>\n<li>Bump tested up to 6.9.<\/li>\n<\/ul>\n\n<h4>1.1.1 - 24th June 2024<\/h4>\n\n<ul>\n<li>Bump WordPress tested up to field to support 6.8 branch.<\/li>\n<\/ul>\n\n<h4>1.1.0 - 17th November 2024<\/h4>\n\n<ul>\n<li>Introduced \"Customer Is A Guest\" pseudo-role, enabling role restrictions to target guest users.<\/li>\n<li>Fixed a bug which would auto exclude the guest when any role was set as excluded.<\/li>\n<li>Added support for passing a context object to the <code>runthings_wc_coupons_role_restrict_error_message<\/code> filter.<\/li>\n<li>Context includes additional information such as <code>coupon<\/code>, <code>is_guest<\/code>, <code>user<\/code>, <code>allowed_roles<\/code>, <code>excluded_roles<\/code>, and <code>effective_allowed_roles<\/code>.<\/li>\n<li>Improved documentation for filters, including usage examples and detailed context information.<\/li>\n<li>Updated screenshots.<\/li>\n<\/ul>\n\n<h4>1.0.1 - 15th July 2024<\/h4>\n\n<ul>\n<li>Fix code snippet formatting in documentation.<\/li>\n<\/ul>\n\n<h4>1.0.0 - 11th July 2024<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<li>Restrict coupons by role.<\/li>\n<li>Allow coupons by role.<\/li>\n<li>Filter <code>runthings_wc_coupons_role_restrict_error_message<\/code> to customise error message.<\/li>\n<\/ul>","raw_excerpt":"Restrict the usage of WooCommerce coupons based on user roles.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/199415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=199415"}],"author":[{"embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/runthingsdev"}],"wp:attachment":[{"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=199415"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=199415"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=199415"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=199415"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=199415"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/tuk.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=199415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}