Skip to content

WooCommerce Automations

Add a User Role Automatically When a WooCommerce Product Is Purchased

Selling access through a WooCommerce product — a membership tier, a wholesale account, a paid community — and want the buyer's role to update the moment they pay, instead of by hand? Zapify does this with the free A product is purchased trigger and the free Add a role to a user action. No code required.

What this automation does

This automation pairs one free trigger with one free action:

  • Trigger: A product is purchased (WC_PRODUCT_PURCHASED, WooCommerce)
  • Action: Add a role to a user (WP_ADD_USER_ROLE, WordPress)

When an order containing the product you choose reaches a paid status, Zapify adds the role you selected to the customer who bought it.

WooCommerce is required

This automation needs WooCommerce installed and active. If it is missing, Zapify offers to install the host plugin from the trigger picker. WooCommerce is a free Zapify integration.

The customer needs a WordPress account

The role is added to a WordPress user account. Guest checkouts have no account to update, so this automation only affects orders placed by a logged-in customer, or a guest order matched by WooCommerce to an existing account by email.

How to build the automation

Step 1: Create a new automation

  1. In the WordPress admin, go to Zapify → Automations.
  2. Click Add New to open the builder.
  3. Name it clearly, such as Add member role after purchase.

Create Automation Button

Step 2: Add the "A product is purchased" trigger

  1. Click Add Trigger.

Trigger Button

  1. Choose WooCommerce as the app.

Select WooCommerce as the trigger

  1. Select A product is purchased.

Select A Product is Purchased

  1. Set the Product field to the specific product that should grant the role. Leaving it as Any runs the automation for every purchase on the store, which only makes sense if every product should grant the same role.

Step 3: Add the "Add a role to a user" action

  1. Click Add Action.

Action Button

  1. Choose WordPress as the app.

Select Wordpress as Action

  1. Select Add a role to a user.

Select "Add a Role to User" Action

Step 4: Leave the User field empty to target the buyer

The action's User field decides who gets the role. Its description reads "Leave empty to use the user this automation is running for." Because the A product is purchased trigger starts this run, leaving User empty applies the role to the person who bought the product.

Fill in User only when the role should go to somebody else — the account holder on a gifted purchase, for example.

Select User

Step 5: Choose the role

Select the role from the Role field. It lists the roles that actually exist on your site, so pick, for example, a custom Member role you've created for paying customers.

Select Role

Step 6: Decide whether to replace existing roles

The Replace existing roles checkbox controls how the role is applied:

Setting Result
Off (default) The selected role is added; the customer keeps any roles they already have, such as Customer.
On The selected role replaces every role the customer currently has.

For most membership setups, leave it Off so the customer keeps their existing WooCommerce Customer role alongside the new one.

Select "Replace Exesting Role"

Step 7: Set the steps Live and save

Each step has its own switch: Live, Off, or Draft. A new automation starts as a Draft and does nothing until its steps are Live.

  1. Set the trigger and the action to Live.
  2. Click Save.

Set Live Button to activate Automation

Step 8: Test it

Place a test order for the selected product with a logged-in test account and mark it as paid (or use a test payment gateway). Open that user's profile in Users → All Users and check the Role column, or open Zapify → Logs to confirm the run.

Tokens you can use

This automation needs no tokens in the core setup — leaving User empty targets the buyer automatically. The A product is purchased trigger still exposes these tokens if you add further actions, such as a follow-up email:

Token Value
Product IDs / Product names The purchased products
Order ID / Order number Order identifiers
Order total / Currency Order value and currency
Billing email Customer billing email
Billing first name / last name / phone Customer details

PRO feature

Choosing which product fires the trigger is free. Deciding whether to run based on other order data — order total, quantity, an existing role — uses automation Conditions, a PRO feature. See filters and conditions.

Conclusion

With the free A product is purchased trigger and Add a role to a user action, Zapify upgrades a customer's role the moment they pay — no manual role changes after every sale. To keep their profile details in sync at the same time, add update a user's profile when a product is purchased to the same automation, or welcome them with an email when a product is purchased.

FAQs

Is this free in Zapify?

Yes. The A product is purchased trigger and the Add a role to a user action are both free, and WooCommerce is a free Zapify integration.

What happens on a guest checkout?

Nothing changes for that order. Add a role to a user needs a WordPress user account to update, and a guest checkout has none unless WooCommerce matches it to an existing account by email.

Does the customer lose their Customer role?

No, not unless you turn on Replace existing roles. Left off (the default), the new role is added alongside any roles the customer already has.

Can different products grant different roles?

Yes. Create a separate automation for each product, each with its own Product field and Role field.

How do I remove the role later, such as on a refund?

Build a second automation with the An order changes status trigger, watching for the status your refunds move orders to, and pair it with whichever role action the WordPress action list offers for removing a role in your version of Zapify.

Do I need to write any code?

No. Everything is configured in the Zapify visual builder.

Was this page helpful?