Coder Social home page Coder Social logo

frumbert / wp2moodle Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 10.0 75 KB

combination moodle and wordpress plugin for single sign on from wordpress to moodle, including woocommerce intergration

Home Page: http://wordpress.frumbert.org/

PHP 98.57% JavaScript 1.43%
wordpress moodle moodle-plugin wordpress-plugin php

wp2moodle's Introduction

wp2moodle

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

It uses an encrypted link and doesn’t rely on SSL / https (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:

  • The users that created through this plugin can’t sign in to Moodle using their WordPress username – they must sign in from the link this plugin generates.
  • You can’t go in reverse; i.e. 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 values being linked to exist within Moodle (e.g. it doesn't check your work)

Data is encrypted (using aes-256-cbc via openssl) at the Wordpress end and handed over a standard http GET request. Only the minimum required information is sent in order to create a Moodle user record. The user is automatically created if not present at the Moodle end, and then authenticated, and (optionally) enrolled in a Cohort, a Group, or both.

How it works

This plugin allows you to place a shortcode in a post that passes encrypted logon information to Moodle (requires this plugin to be also installed into Moodle). The user will be added to Moodle and optionally enrolled in the specified Cohort(s), Course(s) and/or Group(s). If a user is deleted or suspended in Moodle, they will redirect to an url (either the Moodle login page, or a URL you specify).

Use the Moodle button on the rich editor to insert the shortcode, or enter the details manually using the examples below as a guide.

Example: [wp2moodle class='css-classname' group='group1' cohort='class1' target='_blank' authtext='Please log on']launch the course[/wp2moodle]

Attribute Kind Purpose Example
class optional defaults to 'wp2moodle'; CSS class attribute of link [wp2moodle course='abc1' class='wp2m-link']Open[/wp2moodle]
cohort optional, csv idnumber of one or more cohorts in which to enrol a user [wp2moodle cohort='business_cert3']enrol in Cert 3 Business[/wp2moodle]
group optional, csv idnumber of one or more groups in which to enrol [wp2moodle group='eng14_a,math14_b,hist13_c']Math, English & History[/wp2moodle]
course optional, csv idnumber of one or more courses in which to enrol [wp2moodle course='abc1,abc2,def1']Enrol in 3 courses[/wp2moodle]
target optional defaults to '_self'; href target attribute of link [wp2moodle course='abc1' target='_blank']Open[/wp2moodle]
authtext optional string to display if not yet logged on, can be a shortcode [wp2moodle authtext='Please log on first' course='abc1']Open the course[/wp2moodle]
activity optional, depreciated 1-based index (count) of visible activites [wp2moodle course='abc1' activity='2']Open course page[/wp2moodle]
cmid optional Activity ID to open (e.g. /mod/plugin/view.php?id=XXX) [wp2moodle course='abc1' cmid='4683']Open course blog[/wp2moodle]
url optional Url to open after logon (overrides everything else) /mod/customplugin/index.php?id=123

Note csv means comma separated values, no extra spaces

Requirements

PHP 5.6+ (Reccomended: 7.3 or higher) Moodle 3.1 or above (Reccomended: 3.6.4 or higher, last checked in 3.10.1+) Wordpress 4 or above (Reccomended: 5.2.2 or higher, last checked in 5.7) openssl extension on your php (you probably have this)

How to install this plugin

  1. download the plugin into a zip file named wp2moodle.zip
  2. in wordpress choose Plugins > Add New > Upload Plugin and upload and active the plugin in the normal way
  3. in moodle choose Site Administration > Plugins > Install plugins and upload and activate thie plugin in the normal way

Usage:

You can not use this plugin directly; it is launched by wp2moodle from within Wordpress.

IMPORTANT: when linking to things by their id make sure you use the moodle field id number. This is often blank by default - you need to set it.

Problems?

If you are having problems, try these first. If you raise an issue, let me know ALL the version numbers of your installations, what server platform they are running on, and any relevent error messages, otherwise I won't be able to help.

  1. Confirm that you have the requirement met to run the plugin (e.g. openssl must be installed and show up in phpinfo)
  2. Confirm that your course has the appropriate enrolment providers set up already (e.g. cohort based enrolment or manual enrolment)
  3. Confirm that your shortcode is working in Wordpress
  4. Confirm that you are using the text/string version of an identifier and NOT the numerical id of a course or cohort. the Id Number field is NOT set by default in moodle- you have to add something.
  5. Look in your sites php error log to see if you can see if the plugin is silently throwing an error that you are not seeing on the page. In Moodle you can turn on DEVELOPER DEBUGGING to reveal crashes or error messages.
  6. If you're trying one lookup type (e.g. group) then try switching to a different type (e.g. cohort). This may help me narrow down if it's a particular lookup type that is affected.
  7. If you are using IDNUMBER matching on the user, ensure you have a prefix set and the value isn't clashing with existing user records (e.g. mdlw8_user_mneuse_uix error)

Licence:

GPL3, as per Moodle.

wp2moodle's People

Contributors

frumbert avatar ppv1979 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wp2moodle's Issues

Plugin creating duplicated user account on Moodle

I've been using this plugin for a couple of years now and just started having this issue.

I run Wordpress on 2 separate sites that link to the same Moodle. Both Wordpress sites run exactly the same configuration and sit on the same server, but they have different URLs.

Some users have accounts on both websites (with same username and email) and up until a few months ago, the plugin seemed to work flawlessly matching their details on Moodle and logging them in. But recently, the plugin has started duplicating the account on Moodle for some of these users (with a random username) and if I delete the new Moodle account, the user gets an 'Error Writing to Database' error when trying to login.

Any ideas on why this started happening out the blue?

Enrolment not working

When I add the course='ID1' parameter to the wordpress link, neither the course are opened nor the user is enrolled into the course. The link just opens the dashboard. I have given a custom ID to the course in moodle and opened the course for enrollment by any user.

cmid is not working

[wp2moodle class='css-classname' group='group1' cohort='class1' target='_blank' authtext='Please log on' course='TCPR34' cmid='1887']launch the course act[/wp2moodle]

i am using this shortcode to redirect to moodle activity direct using the wordpress link where 1887 is activity id and TCPR34 is my course idnumber, but it is not working. can you please help me?

Ecommerce Solutions

I just wanted to find out if this works with ANY eCommerce "Downloadable" solution?

User duplication or BDD write problem

Hello,

I followed the old tickets concerning a user creation or duplication bug.

I understand that now we can select the match field between Wordpress and Moodle users.

Here is my example:

We have an external database with users which is used to connect users to Wordpress and Moodle.

Here is the problem :

  • When a user connects to Moodle first and then, some time later to Wordpress and clicks on a link with the shortcode, there is a BDD write error which indicates a duplicate entry that the user exists already. There is no link between the wordpress user and the Moodle user because the identification number is not entered in the Moodle.

https://zupimages.net/viewer.php?id=21/18/8vhi.jpg

However, in the settings of the connection module, I clearly indicated that the match field is the username.

Can you tell me the problem?

Thanks in advance.

Regards,

suspended users allowed to login

Hi @frumbert
We have picked up the following which we would like to know if this can be addressed.

If a user is suspended on Moodle's side, the user can still login using WP2Moodle.

Would it be possible to build a check to prevent the user from logging in if the user has been suspended on Moodle's side.
It would also be great, if we could redirect the user to a page informing them why this is potentially an issue.

Please would you let me know if this is a possibility to add.

Currently the plugin does not respect this.

Looking forward to some feedback
M.

Is it still working?

Hi
This is not an issue, it's just a question to know if this plugin is working in latest versions of moodle and wordpress at december 22.

Thanks!

direct log In to moodle at the same time as Wordpress

Hello,

I am in the process of setting up a connection gateway between a wordpress and a moodle for students.

Here is the goal of the project:

  • students connect to a wordpress portal and, on this portal, there are links to the different pages of an associated moodle such as the schedule, the course lists, etc.
  • The goal is that when the students arrive on the moodle by links, they are automatically authenticated on the Moodle and access the requested page.

I tried your plugin and it works very well for authentication if you add the shortcode to a page and click on the link.

On the other hand, do you think it is possible to execute the shortcode at the time of connection to Wordpress or even to perform identification on the moodle at the time of connection to the Wordpress portal?

Currently, the links to the moodle on the wordpress portal do not work until you click on the link generated by the shortcode. On the other hand, once you are logged into the moodle, you can access the direct links on the portal by being automatically identified on moodle.

In advance, thank you for your answer.

New enrolment not respecting manual enrolment duration

I have set the enrolment duration on "Manual Enrolments" to 60 days for all my courses. When I manually enrol a new user to the course, the 60-day duration is respected.

However, when a user is enrolled via wp2moodle, it shows the participant in the course as "Manual Enrolment", but the enrolment duration is not respected, it keeps the user enrolled forever.

Error writing to database no new user on Moodle

@frumbert
So, the plugin has been working well, thanks

Just recently some users register on WP and then click to goto the classroom, but the plugin is no longer auto logging them in.
We get this message directly after login.

image

Now, we had this last time when users existed, but these users are new, any reason why this would be happening.

Matthew

update moodle settings cia phpmyadmin

@frumbert Would it be possible if you can explain which table the settings are for adding the wordpress keys

We have a connection issue, and cannot login to moodle - due to redirects.

If you can assist, thanks
M.

Compatible with WC payment gateways and Product Bundles?

Hi Frumbert,

I am new to the field of web development, but I am trying to integrate WordPress/WooCommerce with Moodle. I am looking for a plugin that provides both single sign-on and enrollment from WooCommerce to Moodle. From my understanding, your plugin does provide these functionalities, however, the sing-on/enrollment in Moodle courses is not automatic, correct? I mean, after purchasing the course from WooCommerce users need to click on a link (that can be sent to them by email, for example), in order to sign on and enroll in that particular course(s) they purchased. If that's the case, can you please confirm if your plugin is fully compatible with all Woocomerce payment gateways plugins (Stripe, PayPal, credit card, amazon pay) and with the WooCommerce Product Bundles plugin as well?

Thanks!

Error - Invalid User

Hi, I have set this up as per instructions and when first clicking the access link on Wordpress I get the error "Invalid User" but if I go back and try again I can get access to moodle.

Debug info: SELECT id FROM {user} WHERE id IS NULL AND deleted = ?
[array (
0 => 0,
)]
Error code: invaliduser
Stack trace:

line 1562 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
line 1538 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 6395 of /lib/accesslib.php: call to moodle_database->get_record()
line 129 of /lib/classes/event/user_created.php: call to context_user::instance()
line 150 of /auth/wp2moodle/login.php: call to core\event\user_created::create_from_userid()

OpenSSL is installed on Wordpress and I am using the latest version of Wordpress and Moodle 3.8.

The shortcode I use is as follows: [wp2moodle course='Far8' target='_blank' authtext='Please log on']Access Farcura E-Learning[/wp2moodle]

Far8 is the course id number.

The auth key is the same on Moodle and Wordpress.

Have you seen this error before?

Edwiser bridge is installed on Moodle as another site is using that for access to a different course.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.