Jump to content

Vanilla Forums WHCMS Single Sign-On


Recommended Posts

I was looking for a forum that would easily integrate with WHMCS and came across a nice open source forum solution called Vanilla Forums (vanillaforums.org).

 

The following is a quick guide to using WHMCS to sign into Vanilla Forums.

 

-Follow the normal instructions for downloading/installing Vanilla Forums: http://vanillaforums.org/download

 

-Download and unzip the jsconnect plugin to the plugins folder: http://vanillaforums.org/addon/jsconnect-plugin

 

-Go to http://forums.yourdomain.com/settings, then go to Plugins and click enable next to jsconnect.

 

-Click the settings button next to jsconnect

 

-Click Add Connection

 

-Scroll down to the bottom and click Generate Client ID and Secret.

 

-For the Site Name enter your company's name

 

-For the Authentication URL, enter in the url to a page we will create on your WHMCS server.

e.g. https://whmcs.yourdomain.com/forumauth.php

 

-The signin url is a special page on your whmcs server we will setup to allow users to sign to WHMCS than redirect back to the forums.

e.g. https://whmcs.yourdomain.com/forumlogin.php

 

-The Register URL should be a link to signup for an account with your service or register with your WHMCS instance.

 

-Click Save.

 

The next step is setup the authentication script on your WHMCS server.

-Download the jsConnectPHP library from https://github.com/vanillaforums/jsConnectPHP

-Upload the functions.jsconnect.php file to your whmcs directory

-Create a new file in your whmcs directory called forumauth.php with the following code.

Update the clientID and secret variable to match what was generate earlier in the jsConnect screen.

 

<?php

require_once 'functions.jsconnect.php';;

require("dbconnect.php");

require("includes/functions.php");

// 1. Get your client ID and secret here. These must match those in your jsConnect settings.

$clientID = "";

$secret = "";

 

$user = array();

 

if ($_SESSION['uid']) {

$result = mysql_query("SELECT id,email,firstname,lastname FROM tblclients WHERE id=".(int)$_SESSION['uid']);

$data = mysql_fetch_array($result);

$user['uniqueid'] = $data['id'];

$user['name'] = $data['firstname'] . " " . $data['lastname'];

$user['email'] = $data['email'];

}

 

// 4. Generate the jsConnect string.

 

// This should be true unless you are testing.

// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.

$secure = true;

WriteJsConnect($user, $_GET, $clientID, $secret, $secure);

 

 

?>

 

Then create another new file called forumlogin.php with the following code:

Change the $_SESSION['loginurlredirect'], variable to the url for your forums.

 

<?php

 

define("CLIENTAREA",true);

define("FORCESSL",true);

require("dbconnect.php");

require("includes/functions.php");

require("includes/clientareafunctions.php");

 

$pagetitle = $_LANG['clientareatitle'];

 

initialiseClientArea($pagetitle,'','');

$_SESSION['loginurlredirect'] = "http://forums.yourdomain.com";

$templatefile = "login";

outputClientArea($templatefile);

 

?>

 

 

Now go back to your new forums and you will see a signin with Your Company Name button. If the user has already signed in with WHMCS they will be automatically logged in once they press the signin button. If they are not signed into whmcs, they will be redirected to the new login page we just created then redirect back to the forums.

 

If you would like your users to be automatically signed in without having to press the sign in button, you can install the auto sign plugin: http://vanillaforums.org/addon/jsconnectautosignin-plugin

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated