WHMCS SSO with Vanilla Forums

edited January 2016 in Web Development

Based upon the directions found here: http://forum.whmcs.com/showthread.php?48059-Vanilla-Forums-WHCMS-Single-Sign-On I just edited https://github.com/vanillaforums/jsConnectPHP for whmcs V6 and thought I would share the change from dbconnect to init...

**forumauth.php**

 <?php
 require_once 'functions.jsconnect.php';;
 require("init.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);


 ?>
**forumlogin.php 

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

 <?php

 define("CLIENTAREA",true);
 define("FORCESSL",true);
 require("init.php");
 require("includes/functions.php");
 require("includes/clientareafunctions.php");

 $pagetitle = $_LANG['clientareatitle'];

 initialiseClientArea($pagetitle,'','');
 $_SESSION['loginurlredirect'] = "enter your forum url here";
 $templatefile = "login";
 outputClientArea($templatefile);

 ?>

Comments

  • edited April 2016

    Hi,

    I have tried to implement this type of login and I receive a white page after vanilla redirects the user to forumlogin.php

    Is this working in whmcs 6.3 ?

    ps. I installed the automatically signed plugin and is working if the user is already logged in whmcs client page

  • Are you allowing login to the forum directly also? I have turned off forum login login to only allow login through SSO apps.

Sign In or Register to comment.