30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

LearnDash Enroll User

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

Abilitylearndash/enroll-user
ToolsetLearnDash — toolset/learndash
GroupLearnDash › Enrolment & Access
RequiresAcrossAI Pro, plus LearnDash LMS active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI 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

NameTypeRequiredWhat it is
learnerstring | integerYesUser ID, login or email.
product_idintegerYesA course or a group.

What comes back

NameTypeWhat it is
product_typestringWhether it was a course or a group.
courses_grantedintegerHow many courses the learner gained.
changedbooleanFalse when they already had it.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent 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


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading