Skip to content

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

  1. In the WordPress admin, go to Zapify → Automations.
  2. Click Add New to open the builder.
  3. Name it clearly, such as Remove student role on course removal.

Create a new automation

Step 2: Add the "A user is removed from a course" trigger

  1. Click Add Trigger.

Add a trigger

  1. Choose LearnDash as the app.

Select LearnDash as the trigger

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

Select A user is removed from a course

  1. 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

  1. Click Add Action.

Add an action

  1. Choose WordPress as the app.

Select WordPress as the action

  1. Select Remove a role from a user.

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.

Choose the role to remove

Step 5: Set the steps Live and save

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

Set the automation live

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

  1. Remove a test student's access to the selected course — cancel a subscription, or use LearnDash's admin screen to revoke access directly.
  2. Check the student's account in Users to confirm the role is gone.
  3. 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.

Was this page helpful?