Wordpress 2 Moodle

What is wp2moodle?


WordPress to Moodle (wp2moodle) is a plugin that allows users in WordPress to open Moodle courses without getting an icky logon box in between. It will also (optionally) enrol the user into cohorts or courses.

It uses an encrypted link and doesn’t rely on SSL (though it’s recommended you use SSL where possible). Your WordPress and Moodle servers might be on the same host, or can be on different networks or server technologies. Since it only uses hyperlinks to communicate, there’s no special setup.

The plugin has these limitations by design:

  • You can’t sign in to Moodle using your WordPress username – you must sign in from WordPress.
  • You can’t log onto Moodle and be signed back into WordPress (using those users – other auth plugins still work)
  • WordPress is not notified of any course results
  • WordPress is not notified of any changes to the user profile done by Moodle (though the plugin normally disables the password)
  • WordPress has no way of knowing if the id’s being linked to exist within Moodle

Plugin Support

If you find a problem with the plugin and you have a GitHub account, please log the issue directly through the GitHub Issue Tracker. If you do not have a GitHub account, then you can also use the CourseSuite HelpDesk (no signup needed).


Launch App

Documentation & Tutorials

Source / Download

Installation into Wordpress

The installation process in WordPress should be familiar to anyone who has installed plugins before. First you will need to download the latest version of plugin from GitHub.

Note: You should rename the zip file to wp2moodle.zip. Sorry about that.

Use the ‘Add Plugins’ feature of WordPress to upload the zip file, and then activate the plugin.


Next, use the new “wp2Moodle” icon to manage the settings. The settings page has more information about the shortcodes and also with its integrations with MarketPress and WooCommerce.

There’s not much to set – just specify the actual url that opens the front page of your Moodle site. For instance, if your site is in a subfolder, specify the url including that subfolder. Do not include a trailing slash.


Next, edit your posts or pages and enter the shortcodes using the standard WordPress editor toolbar:


Installation into Moodle

The installation in Moodle involves downloading the latest version of the plugin, unzipping it (and renaming it), and uploading the file to your moodle’s “auth” folder, then activating the plugin, the configuring it. Lets detail that, since it can be a little tricky.

After the plugin is has been downloaded and unzipped, you may need to rename it. This is because of naming conventions within GitHub – sorry!The folder should end up being called wp2moodle.


Use your usual method for uploading files to your Moodle web server so that it exists in the ~/auth/wp2moodle folder. Make sure you apply the correct permissions to the file as per other uploads.


In Moodle, log on with your administrator account and activate the plugin by clicking on the Site Admin > Notifications link. You should see something like:


After installation, look at the Manage Authentication screen (Site Administration > Plugins > Authentication > Manage authentication) and enable then configure the plugin.


The most important setting here is to match the Encryption Key value to the same setting as was set in the WordPress plugin.


Save your changes, then (if required) configure your courses and cohorts and groups to allow enrolment from the plugin.

Setting up in Wordpress

Edit your posts or pages and enter the shortcodes using the standard WordPress editor toolbar: file

Attribute Meaning
class the css classname to apply to the link (default: wp2moodle)
target the hyperlink target name to apply to the link (defaut: _self)
cohort (optional) the id [mdl_cohort.idnumber] of the moodle cohort in which to enrol the user (can be a comma-seperated list for multiple enrolments)
group (optional) the id [mdl_groups.idnumber] of the moodle group in which to enrol the user (can be a comma-seperated list for multiple enrolments)
course (optional) the id [mdl_courses.idnumber] of the moodle course in which to enrol the user (can be a comma-seperated list for multiple enrolments)
authtext (optional) the text that appears instead when the user is not yet logged on
activity (optional, number) the numerical index of an activity to open after enrolment. E.g. "2" will attempt to open the second activity in the destination course.

E-Commerce Integration

MarketPress and WooCommmerce are both popular e-commerce store fronts for Wordpress but both have the same concept of a digital product - that of a downloadable thing rather than access to a link. You can't just generate the link then redirect to it within the administrative product menus in those tools, since the link needs to represent the user performing the checkout.

wp2moodle goes for a "creative" solution (i.e. a bodgy hack) in that it hooks into the product download functions of these plugins and over-rides them.

Taking WooCommerce as an example (the same setup works in MarketPress), you need to perform these steps:

  1. Create a new plain text file on your computer and edit it (use Notepad or TextEdit)
  2. On each line of the file, add the shortcode attrbutes you need on each line, with an equals between values. Avoid extra spaces! You can use any of the following terms: course, group, cohort. It might look something like this:



  3. Rename the file so that it has a name that ends with -wp2moodle.txt
  4. Upload this file as the products digital download (and set it as virtual so that it doesn't have a stock level)


Setting up in Moodle

When setting up Moodle to receive authentications, you often need to specify an idnumber to link to. This is not the same as the number of the course that you see in the URL, nor is is the name of the course. Why? Because of translations, backups and copies. The idnumber of a course is meant for internal use such as through API's or utilities and isn't shown anywhere on Moodle's screens.


Courses, Groups and Cohorts in Moodle all have an ID Number. You can type in anything you like here, but it's often useful to have a standard you follow, such as the first few letters of the course and category plus a number.

Login to access apps.

When you purchased an app we sent you a password so you can log in. Leave the field empty if you can't remember it and we will send you a new password to use.

You'll remain logged on until you log off (uses a cookie).