Search code examples
phpwordpressiframemoodlebbpress

How to implement Moodle and Wordpress SSO?


I have a Moodle(3.0) website and a WordPress blog (3.5.4). I need to implement SSO between these two.

Here is the basic idea why I want to do it:

Some of the courses in Moodle contain external content (load a page with resources in iframe). At the bottom of the iframe page, that is loaded there is a bbPress embedded (Forum plugin for WordPress).

I need the SSO, so when user logs in his moodle account and choose to view certain resource to be able to participate in the forum topic under the resource without the need of login again.

I've read Authenticate Users From Moodle Into WordPress, and tried to configure External database Authentication Method in Moodle, but so far no luck.

I've found an WordPress plugin Edwiser Bridge, but it makes quite the opposite (integrates Moodle within WordPress) - which is of no use to my particular case.

I will much appreciate every help I can get. Thanks


Solution

  • I ended up building an API, which makes the handshake between Moodle and Wordpress.

    I've modified the moodle/login/index.php page and wp-login.php to send requests to the API when logging in.

    Every time someone logs in either platform a request is being sent to the API. It tries to log the user programmatically and start a session cookie for the user. (if the username and password match in the db).

    When user is being registered the user data is stored in both databases (Moodle and Wordpress).

    NOTE: This is not exactly SSO, but it solved my problem and its working.