LearnDash Automations
Remove a User Role When They're Unenrolled From a LearnDash Course
If enrolling a student adds a role — say a student role that unlocks a members-only area — losing access should take it back. Otherwise a cancelled subscriber keeps a role that no longer matches what they can see. Zapify does this with the A user is removed from a course trigger and the Remove a role from a user action.
What this automation does
The automation is one trigger plus one action:
- Trigger: A user is removed from a course (
LEARNDASH_COURSE_UNENROLLED, LearnDash) - Action: Remove a role from a user (
WP_REMOVE_USER_ROLE, WordPress)
When a student's access to the course you choose is revoked, Zapify removes the role you specify from their WordPress account.
Zapify listens on LearnDash's learndash_update_course_access hook, taking only the removal half of that event. The grant half is a separate trigger: a user is enrolled on a course.
Before you start
- LearnDash must be installed and active.
- Zapify PRO must be active, since LearnDash is a PRO integration.
- The role you want to remove must already exist, and the course must already exist.
PRO feature
LearnDash (learndash) is a Zapify PRO integration. The trigger requires an active PRO licence. The Remove a role from a user action itself is free (WordPress).
How to build the automation
Step 1: Create a new automation
- In the WordPress admin, go to Zapify → Automations.
- Click Add New to open the builder.
- Name it clearly, such as Remove student role on course removal.

Step 2: Add the "A user is removed from a course" trigger
- Click Add Trigger.

- Choose LearnDash as the app.

- Select the trigger A user is removed from a course.

- In the trigger's Course field, pick the specific course, or leave it on Any course.
Step 3: Add the "Remove a role from a user" action
- Click Add Action.

- Choose WordPress as the app.

- Select Remove a role from a user.

Step 4: Configure the action
| Field | Required | What it does |
|---|---|---|
| Role | Yes | The role to take away — pick from your site's registered roles. |
| User | No | Leave empty to use the person the automation is running for — the student losing access. |

Step 5: Set the steps Live and save
- Set both the trigger and the action to Live.
- Click Save.

Tokens this action makes available
| Token | What it holds |
|---|---|
| User ID | The ID of the user the role was removed from. |
| Removed role | The role that was taken away. |
How to test it
- Remove a test student's access to the selected course — cancel a subscription, or use LearnDash's admin screen to revoke access directly.
- Check the student's account in Users to confirm the role is gone.
- If the role wasn't removed, open Zapify → Logs to see whether the run fired and what it reported.
Conclusion
With the A user is removed from a course trigger and the Remove a role from a user action, Zapify keeps WordPress roles in sync with course access instead of leaving stale permissions behind. Next, do the reverse when access is granted with add a role to a user when they're added to a LearnDash group, or see the full picture in triggers and actions.
FAQs
Does this fire on every way access can be removed?
Yes. LearnDash fires learndash_update_course_access for the removal whether an admin revoked access by hand, a subscription expired, or another automation removed it — the trigger covers all of them.
Is this feature free?
The Remove a role from a user action is free. The trigger is part of the LearnDash PRO integration, so it needs an active PRO licence.
Can I remove more than one role?
Yes. Add a second Remove a role from a user action with a different role.
What if the user doesn't have the role to begin with?
Nothing changes — WordPress simply reports that the user doesn't have it, and the action logs accordingly.
Do I need to write any code?
No. Everything is configured in the Zapify visual builder.