🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Moodle Premium Add-on Setup Guide

Updated 8 min read Gravity Forms Integrations A–Z
On this page
  1. Video walkthrough
  2. What you need
  3. Turn on Web Services in Moodle
  4. Choose the functions the token may use
  5. Create the token
  6. The settings page
  7. The Moodle site URL
  8. The token and the connection test
  9. Add a Moodle feed to a form
  10. Course id and role id
  11. Map the fields
  12. When the account does not exist
  13. When to enrol
  14. What a visitor sees
  15. What the add-on records on the entry
  16. Security and privacy
  17. Troubleshooting

Video walkthrough

Gravity Forms Moodle Add-On Setup Guide: Site URL, Token and Course Feed (WordPress Side)
Video setup guide: Gravity Forms Moodle Watch on YouTube

The Gravity Forms Moodle Premium Add-on turns a Gravity Forms submission into a Moodle course enrolment. When someone fills in your form, the add-on looks the person up in your Moodle by their email, enrols them into the course and role you chose, and — if they do not have an account yet — can create the account first and then enrol it. A sign-up form becomes a finished enrolment, with nothing to copy across by hand.

Everything runs through your own Moodle, over its Web Services REST interface, with a token you create. The request goes straight from your WordPress server to your Moodle site; nothing passes through GravityExtra. Your token is kept encrypted on your site, and the add-on only ever contacts the Moodle address you configured.

What you need

  • WordPress with Gravity Forms 2.9 or newer.
  • PHP 7.4 or newer.
  • An active license key for this add-on.
  • Your own Moodle site (self-hosted or hosted), with permission to turn on Web Services and create a token.

If Gravity Forms is missing or older than 2.9, the add-on shows a notice in the WordPress admin and does nothing else, so a form is never left half connected.

Turn on Web Services in Moodle

Moodle talks to the outside world through its Web Services. They are off on a fresh site, so the first job is in Moodle, not WordPress. Sign in to Moodle as an administrator and open Site administration → Advanced features, then tick Enable web services and save.

Next, open Site administration → Server → Web services → Manage protocols and enable the REST protocol. The REST protocol is the one this add-on speaks; the others can stay off. With web services on and REST enabled, your Moodle is ready to accept calls.

Choose the functions the token may use

A token in Moodle is tied to a service, and a service lists the exact functions it allows. Create a service under Web services → External services (or use the built-in one), and add the functions this add-on needs:

  • core_webservice_get_site_info — used by the connection test on the settings page.
  • core_user_get_users_by_field — to find a user by email.
  • core_enrol_manual_enrol_users — to enrol a user into a course.
  • core_user_create_users — only if you want the add-on to create the account when it is missing.

Create the token

Open Site administration → Server → Web services → Manage tokens and create a token for a Moodle user who is allowed to enrol people and, if you need it, create users. Manual enrolment also needs the Manual enrolment method to be enabled on the courses you will enrol into. Moodle shows the token as a long string of letters and numbers — copy it, because you will paste it into the add-on in a moment, and treat it like a password.

The settings page

Install and activate the add-on like any plugin, after Gravity Forms. Then open Forms → Settings → Moodle. This one page holds the license key, your Moodle site address and the Web Services token.

The Moodle settings page in Gravity Forms: license key, the Moodle site URL, the Web Services token field and a connection status line showing the Moodle site name and version
The settings page: your Moodle site URL, the token, and a live connection check.

The Moodle site URL

In the Moodle site URL field, type the web address of your Moodle, for example https://learn.yourschool.com. Enter the site root; the add-on adds /webservice/rest/server.php for you, so you do not have to remember the exact endpoint. If your Moodle lives in a subfolder, include it, for example https://yourschool.com/moodle. If you paste the full endpoint by accident, the add-on trims it back to the site root.

The token and the connection test

Paste the token into the Web Services token field. The token is stored encrypted at rest, so the plain value is never left sitting in the database. After the field is saved it is shown blank, and you can replace it at any time by typing a new one; leaving it blank keeps the token you already saved.

Below the fields is a connection line. When a site URL and a token are saved, the add-on makes one small call to Moodle and shows the result: a green note with your Moodle site name and version means the token works and the add-on can reach your site; a clear message tells you if the token is wrong, the site URL is off, or web services are not switched on. Check it once after you paste a new token, so you catch a typo here and not from a student who cannot be enrolled.

Add a Moodle feed to a form

A feed is a rule that says “when this form is submitted, enrol the person into this course.” Open the form you want, go to Settings → Moodle inside that form, and add a feed. You can add several feeds to one form, each with its own course, role and conditions.

Course id and role id

The Course ID is the number of the Moodle course to enrol into. Open the course in Moodle and read the id from the address bar; it is the number in course/view.php?id=NN. The Role ID is the role the person is given in the course. On a default Moodle, 5 is the Student role, which is the usual choice; your site may differ, and you can see every role and its id under Site administration → Users → Permissions → Define roles. Both fields take a positive whole number, and the add-on checks that before it saves.

Map the fields

Under Map fields, connect your form fields to the person’s details. The email is required: it is how Moodle finds the user, and how a new account is addressed. You can also map a first name, a last name and a username. The username is optional — when you leave it unmapped and the add-on has to create an account, it builds a username from the email address.

When the account does not exist

Not everyone who fills in your form will already have a Moodle account. The Create the Moodle account option decides what happens then. Leave it off and only people who already have an account with the submitted email are enrolled; a submission from someone without an account is noted on the entry and skipped. Turn it on and the add-on creates the account first, with the mapped name and username, and then enrols it.

When the add-on creates an account, the second option decides the password. With Let Moodle create the password on, Moodle makes the password and sends its own welcome email, so the person is invited to set their details; your Moodle must allow that email. With it off, the add-on sets a strong random password the person never sees, and they use the forgot password link to choose their own. Either way, the add-on never stores the password.

When to enrol

Finally, Conditional logic lets a feed run only when the submission matches a rule, for example only when a “Course” dropdown has a certain value, or a payment field is marked paid. With several feeds and different conditions, one form can enrol different people into different courses from the same page.

What a visitor sees

On the front end, nothing changes for the visitor: they fill in your form and submit it as usual. The enrolment happens quietly on your server after the entry is saved, so the person is never kept waiting on a call to Moodle, and a slow or failed Moodle request never stops them submitting.

A front-end Gravity Form for course enrolment with name, email, preferred username and a dropdown choosing the course
An ordinary form; the Moodle enrolment runs on the server after submit.

What the add-on records on the entry

Every submission that runs a Moodle feed gets a note on the entry. When it works, the note says the person was enrolled into the course and role, and whether the account was created or already existed. When it does not, the note says exactly why — a wrong token, a course that does not exist, a role that cannot be assigned, or a network problem — so you can fix it and, if you like, re-run the feed from the entry. The email in every note is masked (for example a***@school.example), so the full address is not left in your notes.

A Gravity Forms entry page showing the submitted fields and a Moodle note recording that the person was enrolled into the course and role
The entry keeps a Moodle note with the result, the email masked.

Security and privacy

Your Web Services token is encrypted with AES-256-GCM before it is saved, using key material from your site’s own secret salts, so a copy of the database alone cannot read it. The token is sent to Moodle only in the body of the request, never in the URL, so it is not written to a server access log. It is never shown again after you save it, never written to an entry, and never put in a note. The add-on contacts only the Moodle address you configured, and the enrolment runs server to server, so the person’s browser never talks to Moodle.

Troubleshooting

  • “Invalid token” — the token is wrong or has been removed in Moodle, or the token’s service does not include the functions above. Make a fresh token and paste it again.
  • “The answer was not JSON” — the site URL is probably not the Moodle root, or web services and the REST protocol are not switched on. Re-check the two Moodle settings.
  • “Cannot assign role” — the token’s user may not enrol in that course, or manual enrolment is not enabled on it. Enable the Manual enrolment method on the course and check the user’s permissions.
  • Nobody is enrolled — check that the feed’s conditional logic is met, that the license is active, and that the mapped email field holds a valid address.

With web services on, a token in place and a feed mapped, the add-on quietly turns each matching submission into a Moodle enrolment, and keeps a clear record on every entry of exactly what happened.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr