DFX Automatic Role Changer for WooCommerce

Description

This plugin allows the association of a role to a WooCommerce product so the role is assigned to a registered user when the product is purchased.

Overview

The DFX Automatic Role Changer for WooCommerce plugin automates the assignment of user roles based on product purchases. This powerful tool streamlines store management by ensuring users are automatically assigned the appropriate roles, enhancing membership sites, subscription-based models, and more.

Features

  • Automatically assign roles to users upon product purchase.

  • Integrates seamlessly with WooCommerce.

  • Premium: Supports the definition of different roles for variations in variable products.

  • Premium: Allows defining, per product, a role validity period in days after the purchase, so the role granted in the purchase will be automatically removed after that period.

  • Premium: Supports role management tied to subscription products, supporting WooCommerce Subscriptions,
    YITH WooCommerce Subscription and
    WP Swings Subscriptions for WooCommerce.

  • Premium: Allows defining multiple roles per product.

Configuration

Setting Up Role Assignments

  • Edit a product from your catalog.

  • Choose the role (or several roles PREMIUM) to assign when the product is purchased.

  • Premium: Define a role validity period in days after the purchase.

  • In WooCommerce > Settings > Role Changer you can configure advanced settings to fine-tune role assignments, such as defining if the new role must be added to the user,
    or if the new role should just replace the previous one.

  • Save changes.

Premium Features

Define Role Validity Periods

The premium version allows defining a role validity period in days after the purchase. The role granted in the purchase will be automatically removed after that period.

Manages roles following the lifecycle of subscription products

The premium version supports advanced functionality for subscription products,
supporting WooCommerce Subscriptions,
YITH WooCommerce Subscription and
WP Swings Subscriptions for WooCommerce,
assigning roles based on subscription status:

  • Active: Assigns a role when a subscription is activated.

  • Suspended: Updates the user role if a subscription is suspended, or is waiting for renewal.

  • Cancelled: Removes or changes roles when a subscription ends.

How to Enable

  • Purchase the premium version of the plugin via the official site

  • Upload and activate the premium plugin.

  • Navigate to WooCommerce > Settings > Role Changer.

  • Enable subscription-based role assignments.

Frequently Asked Questions (FAQs)

1. What happens if a user purchases multiple products with different role assignments?

The plugin can be configured to add roles, or to replace roles.

  • If the plugin is configured to replace roles, the user will remain with the last-assigned role.
  • If the plugin is configured to add roles, all the roles will be assigned to the user. We recommend using a plugin like “Members” to manage multiple roles per user.

2. What happens if a user purchases a product granting a role several times?

In the Premium version, the validity period for a purchase is added to the previously existing one.

3. Can I assign multiple roles to a single product?

In the Premium version you can assign multiple roles. Users will gain all assigned roles upon purchase.

4. How do I upgrade to the premium version?

Visit the official plugin page to purchase the premium version. After purchasing, install and activate it like the free version.

Troubleshooting

Common Issues

Issue: Role changes are not applied after purchase.

Solution: Ensure the plugin is activated and configured correctly under WooCommerce > Settings > Role Changer.

Issue: Subscription-based role changes are not working.

Solution: Verify that the premium version is installed and active.

Issue: Conflicts with other plugins.

Solution: Disable other role management plugins to check for compatibility issues.

Support

For support, visit the plugin support forum.

License

This plugin is distributed under the GNU General Public License v3. For details, refer to the license file included with the plugin.

Credits

Author: David Marín Carreño

Website: https://davefx.com/en/wordpress-plugins

Installation

Prerequisites

  • WordPress 5.0 or higher.

  • WooCommerce 8.0 or higher (tested up to version 10.7).

Steps

  • Download the plugin from the WordPress Plugin Directory.

  • Log in to your WordPress admin dashboard.

  • Navigate to Plugins > Add New.

  • Click Upload Plugin, then select the plugin file.

  • Click Install Now, then Activate Plugin.

Reviews

4 ខែ​មករា, 2023
This plugin is both simple and efficient if you need an automatic system in adding a second user role. Thank you for making this solution!
10 ខែ​មីនា, 2021 1 reply
I looked a time for a plugin like this. Its short, nice and work well. Should be up to date with WP-versions…
19 ខែ​មករា, 2021
The DFX Automatic Role Changer for Woocommerce plugin does very well what it says. A very useful plugin if you know what to do with it. 🙂 A big thanks to the author!
Read all 6 reviews

Contributors & Developers

“DFX Automatic Role Changer for WooCommerce” is open source software. The following people have contributed to this plugin.

Contributors

“DFX Automatic Role Changer for WooCommerce” has been translated into 2 locales. Thank you to the translators for their contributions.

Translate “DFX Automatic Role Changer for WooCommerce” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

20260522.3

  • Widened the supported WooCommerce range: now works on WC 8.0+ (previously implicitly required WC 9.5+). Inlined the Automattic\WooCommerce\Enums\OrderStatus constants to plain strings and gated Automattic\WooCommerce\Utilities\OrderUtil with class_exists, so older WooCommerce installs no longer fatal-error.

  • CI now also runs the test suite against WooCommerce 8.0, 9.5, and 10.7 in addition to the four PHP versions.

20260522.2

  • Bumped the declared WooCommerce requirement to match the code: now requires WC 9.4+ (was 3.0, but the plugin uses the Automattic\WooCommerce\Enums\OrderStatus enum which only exists in WC 9.x+). Tested up to WC 10.7.

  • Premium: Guarded the role-assignment $_POST read with isset() so saving a product without the role field no longer throws a PHP 8 warning.

  • Premium: Removed unreachable code in extract_validity_from_role (multi-grant aggregation actually happens upstream in add_expiration_to_roles).

  • Removed the unused add_settings_tab() method.

  • CI now runs the test suite across PHP 8.0, 8.1, 8.2, and 8.3.

20260522.1

  • Premium: Fixed the “Multiple expiration mode” setting that was silently non-functional in the admin UI (the setting array was missing the id field, so WooCommerce never persisted it). The min/max option labels were also swapped — they now match the underlying behavior.

  • Fixed a race in replace_roles mode when a single user has two or more active role-granting orders. The plugin now tracks managed roles separately so subsequent grants don’t overwrite the user’s original roles, and refunds restore the right state regardless of the order in which they happen.

  • Declared a minimum PHP version (8.0) in the plugin header.

  • Fixed the Domain Path plugin header (was /lang, the directory is /languages).

  • Premium: User display names and URLs are now HTML-escaped in order notes.

  • Declared previously-dynamic properties on the premium class (avoids the PHP 8.2 deprecation notice).

20260522

  • Fixed a deprecated Action Scheduler API call (next() get_date()).

  • Defensive iteration over the user subscription list returned by YITH WooCommerce Subscription, preventing rare fatal errors on role unassignment.

  • Null-order guard in the internal dfx_woo_role_changer_role_maybe_assigned action so subscription paths no longer fatal when the associated order isn’t available.

  • Premium: Fixed the Subscriptions For WooCommerce (WP Swings) integration under HPOS. Subscription status changes weren’t triggering role assignments because the plugin was listening on hooks that don’t fire under HPOS; switched to woocommerce_new_order / woocommerce_update_order.

  • Added a PHPUnit integration test suite covering the free and premium paths, including all three supported subscription providers.

20260521

  • Upgraded Freemius SDK from 2.11.0 to 2.13.1.

  • Marked plugin as tested with WordPress 7.0.

20250325

  • Premium: Added support for definition of roles in variations of variable products.

  • Premium: In case of having one order with several products granting the same role, we can now select how to calculate the validity period (if defined).

20250204

  • The role selector is now rendered as a Select2 dropdown, allowing an easier selection of roles.

  • Premium: Added support for roles with a validity period. The role granted in the purchase will be automatically removed after that period.

  • Premium: Added support for multiple roles per product.

20250203

20250130

  • If the plugin is configured to replace roles (not adding them), now we won’t ever replace the administrator role after
    a purchase if the user had this role before the purchase.

20250127

  • Upgrading Freemius SDK

20250122

  • Changed Freemius installation path.

20250121

  • Premium Feature Added new premium features to allow the role to be assigned/deassigned according a WooCommerce subscription lifecycle.
  • Added messages to promote the premium features.

20240616

  • Added new settings page into WooCommerce Products admin page.
  • Adding new feature to select when the role must be assigned to the user.
  • Adding new mode selection, to determine if the new role must be added to the user or if the new role just should replace any previous role.
  • Added code to be executed if the order gets cancelled or refunded, to remove the role from the user.

20240319

  • Marking compatibility with HPOS.

20201115

  • Initial release