One of our clients has a large eLearning website that we maintain.
They’re based out of Bangkok, so they flew me up for some onsite work, part of which culminated in this plugin here.

eFront is a Learning Management System, similar to Moodle.
Its billed as a User Friendly Learning System, although having used it, I’d say thats a bit of a white lie! :)

More on eFront here – http://www.efrontlearning.net/

eFrontWPI Plugin Overview

This plugin provides single login functionality for WordPress / BBPress and eFront

It will optionally create an eFront user if one does not exist (option to set this in plugin settings).
For login to function the WordPress user and password must be the same as the eFront username and password.

Plugin is based on the v1 api provided by eFront. Should work with v2 also.
To use the v2 api, simply change the eFront URL to the appropriate URI

IMPORTANT NOTE:
This plugin requires cURL (php5_curl) to be installed as a pre-requisite.

Instructions

Upload this folder into your wordpress / bbpress plugins folder.

Typically ->
[your wordpress folder]/wp-content/plugins/

Activate plugin, then go to eFrontWPI Plugin Settings, and enter the appropriate data:

* eFront URL should be the full URI for the eFront API on your server.
eg

http://www.yourservername.com/eFront/www/api.php

or

http://www.yourservername.com/eFront/www/api2.php

* Admin Login
The eFront Admin user (suggest create a user for the API to use)

* Admin Pass
The eFront Admin user pass

* Create User checkbox
Check if you want a user automatically created.

* Current eFront token
This is a read only field which shows the current eFront API token (if any).
This is a good way to check if the plugin is working – if you have a token, it should be working.

Download here – eFrontWPI v1.0

13 Comments to “eFrontWPI – WordPress integration Plugin for eFront”

  • Zach says:

    Thank you so much for creating this!
    I went ahead and installed the plugin and received the token indicating that it’s working properly. I created a user in wordpress and nothing appeared in the eFront user screen. I then logged out of both and returned to the admin panel and tried again. Still nothing.
    I also tested api.php with http:/website/efront/www/api.php?action=token and received the token.

    Can you think of anything I may have missed?

    eFront Version: 3.6.7 Community
    Wordpress Version: 3.0.4

  • What API are you using? api1 or api2?
    Do you have php5_curl installed?
    Have you checked the create a user box?

    Its not difficult code really, the gist of it is that it adds a hook into the authenticate filter in WordPress.

    If the user can login, it tries to login to eFront also (via the eFront API).
    If the user doesn’t exist it will create a new eFront user (if set to do so in the plugin admin in WordPress)
    It will then attempt to login with the new user account in eFront.

    eFront login works on a cookie basis.

    If you are still having issues, suggest Firefox and Firebug, then take a look at cookies before and after login to see if the cookie is indeed being created.

    Its possible a newer version of either WordPress or eFront have depreciated one of the calls I use; let me know what you see so I can update the plugin if necessary.

    Lawrence.

  • One other thought –

    eFront uses a hard coded cookie key – that may have changed.
    If so, I’ll probably need to add that in as a variable to be set in the plugin admin also.

    Check to see if this is still the same in your version of efront.
    //G_MD5KEY from eFront libraries/globals.php
    //eFront needs a cookie also.
    define(“G_MD5KEY”, ‘cDWQR#$Rcxsc’);

  • I think its probably going to be the cookie..

    I think I’ll need to make a minor change to load the eFront libraries/global.php directly, so that any change would use their md5 salt du jour.

    I’ve made some small changes to do so – see below for what to change.
    Can you try this in your side and see if this works (or gives an error), then let me know!
    Then I can either remedy,or update the plugin zip file to include this.

    Open eFrontWPI.php in the wordpress plugins folder, and change the eFrontWPI_set_cookie code to the below.

    function eFrontWPI_set_cookie($username,$password) {
    //G_MD5KEY from eFront libraries/globals.php
    //eFront needs a cookie also.
    //define(“G_MD5KEY”, ‘cDWQR#$Rcxsc’);

    global $eFrontWPI_options;

    $myfile = $eFrontWPI_options['path'] . ‘/libraries/globals.php’;

    if (($file_handle = @fopen($myfile, ‘r’)) === false) {
    //Can’t find the globals file
    return new WP_Error(‘eFrontWPI_server_error’, __(‘eFrontWPI: Attempted to load globals.php file, but failed. Does this path look correct: ‘.$myfile));
    }
    else {
    @include $myfile;
    //define(“G_MD5KEY”, ‘cDWQR#$Rcxsc’) should be defined from above include..
    }

    setcookie(“cookie_login”, $username,time()+3600,’/');
    setcookie(“cookie_password”, md5($password.G_MD5KEY),time()+3600,’/');
    }

  • Zach says:

    I’ve tried both APIs and tested manually.
    I do have Curl installed and verified in phpinfo.
    I tested with and without the create user option.

    I replaced
    eFrontWPI_set_cookie($username,$password);
    return;
    with your fix and I now receive a 500 error when trying to login.

    This is how I placed it in eFrontWPI.php

    if (strpos($result, ‘user does not exist’) == true ) {
    if ($eFrontWPI_options['create_login'] == ‘yes’) {
    //Add the user if possible.
    eFrontWPI_perform_action (“create_user&login=”.$username.”&password=”.$password.”&name=”.($user->first_name).”&surname=”.($user->last_name).”&email=”.($user->user_email).”&languages=english”);
    eFrontWPI_perform_action (“update_user&login=”.$username.”&password=”.$password.”&name=”.($user->first_name).”&surname=”.($user->last_name).”&email=”.($user->user_email).”&languages=english”);
    }
    }
    function eFrontWPI_set_cookie($username,$password) {
    //G_MD5KEY from eFront libraries/globals.php
    //eFront needs a cookie also.
    //define(“G_MD5KEY”, ‘cDWQR#$Rcxsc’);

    global $eFrontWPI_options;

    $myfile = $eFrontWPI_options['path'] . ‘/libraries/globals.php’;

    if (($file_handle = @fopen($myfile, ‘r’)) === false) {
    //Can’t find the globals file
    return new WP_Error(‘eFrontWPI_server_error’, __(‘eFrontWPI: Attempted to load globals.php file, but failed. Does this path look correct: ‘.$myfile));
    }
    else {
    @include $myfile;
    //define(“G_MD5KEY”, ‘cDWQR#$Rcxsc’) should be defined from above include..
    }

    setcookie(“cookie_login”, $username,time()+3600,’/');
    setcookie(“cookie_password”, md5($password.G_MD5KEY),time()+3600,’/');
    }
    }
    function eFrontWPI_perform_action($action)
    {

    • Make sure that you don’t just copy/paste it in.

      Ensure that wordpress hasn’t munged the characters – especially the ‘s
      If that doesn’t help, comment out all the added code with //at the start of each added line, and then uncomment section by section till it breaks, then fix appropriately.
      eg uncomment if (..) { return wp_error… } see if that is ok. If so, then add in the else { @include .. } see if that works.
      Its only 5 lines of code, shouldn’t take more than a few seconds to see where you’ve gone wrong (or I’ve missed something stunningly obvious).

  • Zach says:

    Ok, it’s no longer throwing errors after trying again, I made a mistake. However, it’s still not adding the user to eFront. Any ideas?

  • Andy says:

    Your crappy plugin corrupted my efront installation. I’m getting a session expired message and there is no way to get it fixed.

    • …and this is why no-one does stuff – all you get is ungrateful people like you complaining.

      No, it did not corrupt your efront installation. You have the source code, all the plugin does is create an efront login cookie for you on login to wordpress. If you have an issue, either delete the cookie, or login from another browser. The only thing broken is your attitude.

      How about – hey, i tried your plugin and have this issue, what could it be.

  • moshe ovadia says:

    hi, Lawrence Sheed
    i know users like Andy, dont let souch ungrateful people destroy your day, keep developing!!

    thenk you

  • Rebecca says:

    Hi lawrence,

    Thanks for developing this.
    However, i’m faced with the same issue, the session expiration issue. My user is connected to eFront. However, when i am trying to enter the administrator or related link, it shows that the session for my user had expired.

    Any idea how to solve this? Much appreciated. Thank You.

Post comment

Archives

Categories

Most Popular Posts

Tags

Recent Comments

  • HenryX: If you have any problems about motocycle , I can answer you. I am a local Shanghaier with a 5 years’...
  • Johnny E: Hi Lawrence.. i have a 1999 Bmw E46 320i, i had to change the engine because it was broken, and now i...
  • Lawrence Sheed: Zoneminder is a video monitoring capture system. I have an IP Camera pointed at the entrance, and...
  • Shaun Wallace: That is pretty cool, and cheap too! I may order one thanks to your recommendation. What is zone...
  • Hector: My country doesn’t require a license for MOPEDS & no highway sticker. Liability and the cost of...

Recent Trackbacks

PHOTOSTREAM

Side Art