Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

vanilla and Wordpress MU integration

edited July 2007 in Vanilla 1.0 Help
This is how I did it.

What I needed to do was:
1. That you could login only from wordpress and couldn't login from vanilla.
2. If you sign out from vanilla you must be signed out from wordpress to and backwards.
3. In vanillas Personal Information you must see yours wordpress First and Last names.

Ok, this is how I did it.

First I integrated files and database as written in http://lussumo.com/docs/doku.php?id=vanilla:integration:wordpress
Only I didn't use versions. So my file integration looks like this:

/path/to/document/root/wordpress/
/path/to/document/root/wordpress/vanilla

Then I created few files:

1. /path/to/document/root/wordpress/logout.php
2. /path/to/document/root/wordpress/wp-admin/vanilla-profile-update.php
3. /path/to/document/root/wordpress/vanilla/logout.php
4. /path/to/document/root/wordpress/vanilla/wordpress-profile-update.php
5. /path/to/document/root/wordpress/vanilla/appg/wordpress_auth.php

1. - /path/to/document/root/wordpress/logout.php
//*****************************************************************
<?php
include("vanilla\logout.php");
?>
//*****************************************************************

2. - /path/to/document/root/wordpress/wp-admin/vanilla-profile-update.php
//*****************************************************************
<?php

include ("../wp-config.php");

if (!($db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)))
{
die("Can't connect to mysql.");
}
else
{
if (!(mysql_select_db(DB_NAME, $db)))
{
die("Can't connect to db.");
}
}

$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$userid = $_SESSION['LussumoUserID'];

$query = "update wp_users set FirstName = '$firstname' where id = '$userid'";
$result = mysql_query($query) or die("Query failed. " . mysql_error());
$query = "update wp_users set LastName = '$lastname' where id = '$userid'";
$result = mysql_query($query) or die("Query failed. " . mysql_error());


?>
//*****************************************************************

3. - /path/to/document/root/wordpress/vanilla/logout.php
//*****************************************************************
<?php
session_start();
session_destroy();
?>
//*****************************************************************

4. - /path/to/document/root/wordpress/vanilla/wordpress-profile-update.php
//*****************************************************************
<?php

include ("../wp-config.php");

if (!($db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)))
{
die("Can't connect to mysql.");
}
else
{
if (!(mysql_select_db(DB_NAME, $db)))
{
die("Can't connect to db.");
}
}

$firstname = $_POST['FirstName'];
$lastname = $_POST['LastName'];
$userid = $_POST['u'];

$query = "update wp_usermeta set meta_value = '$firstname' where meta_key = 'first_name' and user_id = '$userid'";
$result = mysql_query($query) or die("Query failed. " . mysql_error());

$query = "update wp_usermeta set meta_value = '$lastname' where meta_key = 'last_name' and user_id = '$userid'";
$result = mysql_query($query) or die("Query failed. " . mysql_error());

?>
//*****************************************************************

5. - /path/to/document/root/wordpress/vanilla/appg/wordpress_auth.php
//*****************************************************************
<?php


if ($_COOKIE['wordpresspass'] && $_COOKIE['wordpressuser'])
{
include ("conf/database.php");

if (!($db = mysql_connect($Configuration['DATABASE_HOST'], $Configuration['DATABASE_USER'],
$Configuration['DATABASE_PASSWORD'])))
{
die("Can't connect to mysql.");
}
else
{
if (!(mysql_select_db($Configuration['DATABASE_NAME'], $db)))
{
die("Can't connect to db.");
}
}

$query = "select * from wp_users where user_login = '" . $_COOKIE['wordpressuser'] .
"' ";
$result = mysql_query($query) or die("Query failed. " . mysql_error());
$result = mysql_fetch_assoc($result);
$pssw = $result['user_pass'];


if (md5($pssw) == $_COOKIE['wordpresspass'])
{
if (!session_id())
{
session_start();
$_SESSION['LussumoUserID'] = $result['ID'];
}
}

}
else{
session_start();
session_destroy();
}
?>
//*****************************************************************


and some of them included in files:

vanilla/appg/settings.php // - in 31 line include "wordpress_auth.php"
wordpress/wp-login.php // - in 78 line include "logout.php".
wordpress/wp-admin/profile-update.php // - in 26 line include "vanilla-profile-update.php".

In THE BEGINING of file vanilla/account.php added few lines:

if($_POST['btnSave'])
include("wordpress-profile-update.php");

Then change some settings in vanilla/appg/settings.php file:

$Configuration['SIGNIN_URL'] = '../wp-login.php';
$Configuration['SIGNOUT_URL'] = '../wp-login.php?action=logout';


That’s it.

Comments

This discussion has been closed.