learndash/enroll-user gives a learner access to a course, or adds them to a group.
product_id may be either, and the difference in reach is large.
At a glance
| Ability | learndash/enroll-user |
| Toolset | LearnDash — toolset/learndash |
| Group | LearnDash › Enrolment & Access |
| Requires | AcrossAI Pro, plus LearnDash LMS active on the site |
| Capability | manage_options |
| Safety | Writes data |
| Repeatable | Idempotent — running it twice leaves the same result |
| Ships in | AcrossAI Pro 0.9.16 and later |
A group is not one course
Enrolling into a group grants every course that group carries. On a site where groups bundle a dozen courses, that is a dozen enrolments from one call.
So the response reports which kind the product was and how many courses came with it — because the request looks the same either way and the outcome does not.
Already-enrolled users are reported as unchanged rather than treated as an error, which makes bulk enrolment safe to re-run.
The learner can be given as a user ID, a login or an email address. Email is usually what the person asking has, and resolving it here saves a lookup.
learndash/get-access-info first is worth it when the current state matters: somebody who already has access through a group does not need enrolling, and enrolling them anyway creates a direct enrolment that outlives their group membership.
Idempotent.
Input
| Name | Type | Required | What it is |
|---|---|---|---|
learner | string | integer | Yes | User ID, login or email. |
product_id | integer | Yes | A course or a group. |
What comes back
| Name | Type | What it is |
|---|---|---|
product_type | string | Whether it was a course or a group. |
courses_granted | integer | How many courses the learner gained. |
changed | boolean | False when they already had it. |
success | boolean | Whether the call completed. |
message | string | A one-line summary of what happened, suitable for showing a human. |
error_code | string | Present only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation. |
Example
Ask your assistant:
Enrol this person in the onboarding course.
It resolves to one call:
{
"ability": "learndash/enroll-user",
"parameters": {
"learner": "sam@example.com",
"product_id": 412
}
}Worth knowing
- A group grants every course it carries. The response says how many.
- Already enrolled is reported as unchanged, not as an error.
- Learners can be addressed by email.
- A direct enrolment outlives group membership.
Related abilities
- LearnDash Get Access Info — check what they already have
- LearnDash Unenroll User — the reverse
- LearnDash Manage Group Membership — bulk group changes
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category