How to connect Boonex Dolphin and Vanilla Forums using jsConnect SSO

Spread the love

In this tutorial, we assumed that you already have installed Boonex Dolphin and Vanilla Forums on your web server!

jsConnect is a Vanilla Forums plugin that enables custom single sign-on solutions. They can be same-domain or cross-domain.

jsConnect is available for multiple scripting languages, PHP, Java, .NET, Ruby, and Python. Depending on the need we can use any of them. Since Boonex Dophin is based on PHP, in our case we will use jsConnect PHP.

This tutorial is based on Vanilla Forums installed as a separate site either on same-domain or cross-domain but not as an embedded site. So it may or may not work with embedded site!

We require 2 external files, functions.jsconnect.php and index.php available at GitHub. We only have to change index.php file, functions.jsconnect.php remains unchanged!

  1. First, we will have to install Vanilla jsConnect plugin to Vanilla Forums site.
    • Download Vanilla jsConnect plugin from Vanilla Forums Addons
    • Extract the jsConnect plugin and upload it into the /plugins directory where you installed the Vanilla Forums
    • Enable the plugin via logging into Vanilla Admin Panel > Plugins
  2. Setting jsConnect plugin
    • Click on jsConnect settings then Click on Add Connection
    • You will see something like this
    • jsconnectaddconn
    • Click on Generate Client ID and Secret. You will see Client ID and the Secret box is filled up.
    • Enter site name in the Site Name box. It will be shown on the Sign in button. We entered My Dolphin
    • Now comes the most confusing part, Authenticate Url !
      • Rename jsConnect index.php to whatever you want to avoid conflict with Dolphin index.php file. We renamed it to jsconnect.php
      • Drop both the files, jsconnect.php and functions.jsconnect.php to your Dolphin directory. We dropped it to root directory of Dolphin at /public_html/dolphin/ and assumed the site is accessible at
    • Then enter Authenticate Url as (the location of the jsonp formatted authentication data).
    • Enter Sign In Url as
      • The new version of Dolphin doesn’t have Login form on the join page. You will have to add Login form on it. Go to Dolphin Admin Panel > Builders > Pages Builder > Join Page
      • Drag Login box from Inactive blocks to Active blocks
    • Enter Register Url as
    • Enter Sign Out Url as
      • This can be changed depending on how you want to user to logout.
      • Logout from Vanilla Forums but not Dolphin
      • Logout from Vanilla Forums as well as Dolphin (Somehow this do not work currently after the jsConnect plugin is updated)
    • Leave all other to default setting. You can experiment with them later!
    • Note down the Client ID and Secret. You will need that in jsconnect.php file
    • After doing the above steps, It will look something like this
    • jsconnectfilled
    • Click Save. You will see something like this
    • jsconnectsaved
    • Do not click on Test URL yet. You have not yet configured jsconnect.php file
  3. Setting jsConnect PHP index.php (in our case it is jsconnect.php). This is the file which will pass user information to Vanilla Forums.
    • Edit jsconnect.php file. In this file, we will have to create a connection to Dolphin database to fetch information required.
    • Add below code at the starting of the file before
      require_once dirname(__FILE__).'/functions.jsconnect.php';
    • This is the code
    • header('Content-type: application/javascript; charset=utf-8');
      $servername = "localhost";
      $username = "yourdolphindatabaseusername";
      $password = "yourdolphindatabasepassword";
      $dbname = "yourdolphindatabasename";
      $memID = $_COOKIE['memberID'];
      // Create connection
      $conn = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn->connect_error) {
          die("Connection failed: " . $conn->connect_error);
      $sql = "SELECT * FROM Profiles WHERE ID='$memID'";
      $result = $conn->query($sql);
      if ($result->num_rows > 0) {
          // output data of each row
          while($row = $result->fetch_assoc()) {
              $dnick = $row[NickName];
              $dname = $row[FullName];
              $demail = $row[Email];
              $dstatus = $row[Status];
      $sqlpic = "SELECT Hash as pic FROM `bx_photos_main` WHERE Owner = $memID and ID = ( SELECT LastObjId FROM `sys_albums` WHERE Owner = $memID and Uri like '%-s-photos' )";
      $ressql = $conn->query($sqlpic);
      if ($ressql->num_rows > 0) {
          // output data of each row
          while($row = $ressql->fetch_assoc()) {
      	$pic = $row[pic];
      ob_start(); //Start output buffer for full picture
      echo "{$pic}.jpg";
      $dfullpic = ob_get_contents(); //Grab output
      ob_end_clean(); //Discard output buffer for full picture
      ob_start(); //Start output buffer for thumbnail
      echo "{$pic}.jpg";
      $dsmallpic = ob_get_contents(); //Grab output
      ob_end_clean(); //Discard output buffer for thumbnail      
    • Change Client ID and Secret to the value you noted while configuring jsConnect plugin
    • Change these values
         $user['uniqueid'] = $dnick;
         $user['name'] = $dname;
         $user['email'] = $demail;
         $user['photourl'] = $dsmallpic;
      • photourl can be changed as per the need. Even it can be left blank. We left it blank as in both the case there is some issue
      • $dsmallpic : To pass thumbnail picture to Vanilla Forums but then Avatar on Profile page of the user will be blurred as the small image is enlarged to fit the size
      • $dfullpic: To pass full size picture to Vanilla Forums. Avatar on Profile page will be fine but the same full image will be loaded everywhere where thumbnail is used so it will slow the site loading as profile picture of all the user have to be loaded to display it side to discussion bar
      • In any of the above case, the user on Vanilla Forums will be able to set profile picture there. The benefit of setting Avatar there is that, the full picture will be used as the  profile picture and the thumbnail of that same picture will be used side to the discussion bar. So let them set there only!
    • Add below code at the bottom of the file
    • } 
          else {
          echo 'It seems you are not Logged In at My Dolphin or You account is not active. Unable to retrieve data!';
    • Note: In our case we want only Active member of Dolphin to log in on Vanilla Forums so we are checking if the profile is active or not.

      You can change this depending on your need like Approval or Unconfirmed or both. Or if you don’t want to check and allow all member to log in to Vanilla Forums then just remove if condition.

    • Save the jsconnect.php file.
  4. Now click on Test URL in jsConnect plugin setting to see whether this setting works or not. If it works then it will show something like this
    test({"uniqueid":"1","name":"Admin","email":"[email protected]",
  5. Logout from Vanilla Site
  6. Now you will see a new button at left top side Sign in with My Dolphin
    • Click on it, it will redirect you to Dolphin login site. Login there, it will redirect you to Dolphin members page
    • Currently there is no method to redirect back to Vanilla Forums after you login to Dolphin. So after login to Dolphin site, manually go again to the Vanilla Forums site.
  7. You will see Sign in with My Dolphin and above that, your logged in name will be written. Click on it and It will log you in to Vanilla Forums site.
  8. Enjoy Single Sign On

There is another plugin available on Vanilla Forums Addon, Vanilla jsConnect Auto Sign in. If you install it then you will be automatically logged into Vanilla Forums if you are already logged into your Dolphin site.

Here is the complete jsconnect.php configured file for Boonex Dolphin

Just change the following details

  1. Database details
  2. Client ID and Secret
  3. Change website name to your website in echo field under ob_start();

Help us improve this tutorial. Comment your suggestion and problems below!

Spread the love
READ  How forking twice avoids zombie? Understanding the concept!

Leave a Reply

Your email address will not be published. Required fields are marked *