LearnDash Integration
Create (or reuse) a WordPress user and enroll them in a LearnDash course and/or group when a form is submitted.
Action type: learndash
Label: Enroll in LearnDash
Dependency: LearnDash (available only when ld_update_course_access() exists)
Handler: Core_Forms\Integrations\IntegrationHandlers::learndash
Source: src/integrations/class-integration-manager.php, src/integrations/class-integration-handlers.php
Setup
- Make sure LearnDash is installed and active. The action does not appear in the Actions list otherwise.
- In WordPress, edit your form > Actions tab > Add Action > Enroll in LearnDash.
- Select a course, a group, or both, and adjust the contact field mappings if needed.
Settings Reference
| Setting | Required | Default | Description |
|---|---|---|---|
| Yes | [email] |
Learner email; must resolve to a valid address | |
| First name | No | [first_name] |
Learner first name |
| Last name | No | [last_name] |
Learner last name |
| Phone | No | [phone] |
Learner phone |
| Course | No | -- | LearnDash course (sfwd-courses post) to grant access to |
| Group | No | -- | LearnDash group (groups post) to add the user to |
Course and Group are each optional — set one or both. All text settings support Core Forms data variables such as [email] or any form field name.
User Handling
- If a WordPress user with the submitted email already exists, access is granted to that account.
- Otherwise a new
subscriberuser is created. The login is derived from the email's local part (with a numeric suffix on collisions) and the password is a random 24-character string. Core Forms does not email credentials; new learners can set a password through the standard WordPress reset flow.
How It Works
- The user is looked up or created as described above; if that fails the action reports "Could not create the LearnDash user."
- If a course is selected, the user is enrolled via
ld_update_course_access(). - If a group is selected, the user is added via
ld_update_group_access()(when that function is available). - The action log records the user, course, and group IDs.
Each run is idempotent: Core Forms builds a key from the submission ID, action type, and resolved settings, so re-processing the same submission never repeats the enrollment.
Example: Free Course Signup
Form with email, first_name, and last_name fields:
- Course: "Onboarding 101"
- Group: leave empty
On submit, a learner account exists and the course appears on their LearnDash profile immediately. Pair the action with an email action containing a login/reset link.
Troubleshooting
- Action missing from the Actions list: LearnDash must be active; the availability check looks for
ld_update_course_access(). - "Could not create the LearnDash user": The email resolved to an empty or invalid address. Verify the Email setting maps to a real form field.
- User not in the group: Group enrollment requires
ld_update_group_access(); confirm your LearnDash version provides it and that a group was selected. - Nothing enrolled: If both Course and Group are left empty, only the user account is created.