=== Membership & User Roles for WooCommerce (Automatic Role Changer) === Contributors: DaveFX Donate link: https://paypal.me/davefx Tags: membership, user roles, subscriptions, access control, restrict content Requires at least: 6.2 Requires PHP: 8.0 Tested up to: 7.1 Stable tag: 20261205 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Plugin URI: https://davefx.com/en/dfx-automatic-role-changer-for-woocommerce/ Sync user roles with memberships and subscriptions. Grant access on purchase, revoke on expiry, and restrict your store by role. == Overview == The Membership & User Roles 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. It also bridges [MemberPress](https://memberpress.com/) to WordPress roles: a membership's state drives the role, continuously, so access granted in MemberPress is reflected wherever your site checks roles. == Features == * Automatically assign roles to users upon product purchase. * Integrates seamlessly with WooCommerce. * Syncs [MemberPress](https://memberpress.com/) membership state to WordPress roles, continuously — the direction other integrations don't cover. The free version syncs one membership level. * *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](https://woocommerce.com/products/woocommerce-subscriptions/), [YITH WooCommerce Subscription](https://wordpress.org/plugins/yith-woocommerce-subscription/) and [WP Swings Subscriptions for WooCommerce](https://wordpress.org/plugins/subscriptions-for-woocommerce/). * *Premium*: Allows defining multiple roles per product. * *Premium*: Unlimited MemberPress levels, several roles per membership, and mapping of every membership state (pending, active, suspended, cancelled, expired). * *Premium*: Restricts your store by role — hides products and categories from the catalog and search, denies direct URL access, blocks add-to-cart, and sets per-role prices, payment gateways and shipping methods. * *Premium*: Retroactive sync — a batched admin tool that gives existing customers the roles their past orders, memberships and subscriptions should have granted, for stores that configured roles after selling or migrated from another platform. Safe to re-run. == Installation == = Prerequisites = * WordPress 6.2 or higher. * WooCommerce 8.0 or higher (tested up to version 11.0). = 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. == 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](https://woocommerce.com/subscriptions/), [YITH WooCommerce Subscription](https://wordpress.org/plugins/yith-woocommerce-subscription/) and [WP Swings Subscriptions for WooCommerce](https://wordpress.org/plugins/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](https://davefx.com/en/dfx-automatic-role-changer-for-woocommerce/) * Upload and activate the premium plugin. * Navigate to WooCommerce > Settings > Role Changer. * Enable subscription-based role assignments. == Frequently Asked Questions == = 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](https://davefx.com/en/dfx-automatic-role-changer-for-woocommerce/) 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. == Screenshots == 1. Choosing the role a product grants: "Assigned Role", in the General tab of the product's Product data box. == External services == The plugin assigns roles without any external service. Two appear only in the cases described below. = Freemius = [Freemius](https://freemius.com/) handles licensing, the paid plans and updates of the premium version. Nothing is sent to it unless one of the following happens. * **You opt in.** On activation, an administrator is offered "Allow & Continue" or "Skip". Skipping sends nothing. Allowing sends that WordPress user's first name, last name and email address; the site's homepage URL and title, its language, and the WordPress and PHP versions; the plugin and SDK versions; and, from then on, whether the plugin is active, deactivated or uninstalled. The list of installed plugins and themes (names, slugs, versions, and whether each is active) is sent too unless you switch it off: it is a separate, optional permission on the opt-in screen. No newsletter subscription is requested. * **You activate a premium licence key.** The key, the homepage URL, the plugin and SDK versions, and whether the plugin is active are sent, so the licence can be checked and updates delivered only to the sites you authorise. Sending the site title, language, WordPress and PHP versions, and the plugins and themes list is optional at this point; the plugins and themes list starts switched off. * **You answer the deactivation survey and later delete the plugin.** The survey is shown on deactivation and sent when the plugin is deleted. If you never opted in and tick "Anonymous feedback", only the reason you chose, up to 128 characters of any text you typed and an anonymous site identifier are sent. If you submit it without ticking that box, the plugin opts you in at that moment and sends everything listed for opting in above. If you skip the survey, nothing is sent. Once you have opted in or activated a licence, the SDK keeps that information up to date with Freemius periodically. You can opt out later from the plugin's account page. Freemius's [terms](https://freemius.com/terms/) and [privacy policy](https://freemius.com/privacy/) cover what it does with this data. = The "More plugins" section = The "More plugins" section of the plugin's settings (WooCommerce → Settings → Products) lists the author's other plugins from a list included in this plugin; nothing is downloaded. When an administrator opens it, the browser shows those plugins' icons from WordPress.org (ps.w.org), as WordPress's own plugin installer does. == 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](https://davefx.com/en/wordpress-plugins) == Changelog == = 20261205 = * The "More plugins" section no longer downloads anything: the list of the author's other plugins now comes only from a copy included in the plugin, so opening it makes no request to davefx.com. The list cached by earlier versions is deleted. The "External services" section of this readme is updated to match. = 20261202 = * *Premium*: the retroactive sync now also goes through past paid orders. Customers get the role set on the products they already bought, which covers stores that configured roles after selling for a while and stores migrated from another platform, where the orders came across but the roles did not. It follows the "grant moment" setting (a processing order counts only if roles are granted on payment or on processing), replays the oldest orders first so replace mode ends on the latest purchase, and only grants, never removes. Roles with an expiry period are skipped, because their expiry would otherwise start counting from today. Guest orders are skipped too, since there is no user to give the role to. An optional "Only orders placed since" date limits it to recent orders, for stores where roles were removed by hand from customers who bought long ago. = 20261201 = * The "More plugins" section now loads its styles through WordPress's style queue instead of printing a `