Sorry to bug you yet again, but the code doesn't seem to be working for some reason. Both $vbulletin->gpc['password'] and ['vb_login_password'] are coming up blank in the user_login vb event. I tried hardcoding a password into the update statement and it worked, it set the modx password to my hardcoded value. So the problem seems to be getting the password from vbulletin.
Just to be clear I'm posting the entire login part of the xml:
Code:
<plugin active="1" executionorder="5">
<title>Login into ModX</title>
<hookname>login_process</hookname>
<phpcode><![CDATA[
global $vbulletin, $vbphrase;
$modxconfig = $vbphrase['modxpath'] . "manager/includes/config.inc.php";
include($modxconfig);
$c = mysql_connect($database_server, $database_user, $database_password);
mysql_select_db($dbase);
$sql = "SELECT wu.*, ua.* ".
"FROM $dbase.`".$table_prefix."web_users` wu, $dbase.`".$table_prefix."web_user_attributes` ua ".
"WHERE wu.username = '".$vbulletin->userinfo['username']."' and ua.internalKey = wu.id;";
$ds = mysql_query($sql);
$row = mysql_fetch_assoc($ds);
if ($row) {
session_name($site_sessionname);
session_start();
$_SESSION['webShortname']=$vbulletin->userinfo['username'];
$_SESSION['webFullname']=$row['fullname'];
$_SESSION['webEmail']=$row['email'];
$_SESSION['webValidated']=1;
$_SESSION['webInternalKey']=$row['internalKey'];
$_SESSION['webValid']=base64_encode($vbulletin->userinfo['password']);
$_SESSION['webUser']=base64_encode($vbulletin->userinfo['username']);
$_SESSION['webFailedlogins']=$row['failedlogincount'];
$_SESSION['webLastlogin']=$row['lastlogin'];
$_SESSION['webnrlogins']=$row['logincount'];
$_SESSION['webUserGroupNames'] = ''; // reset user group names
// get user's document groups
$dg='';$i=0;
$sql = "SELECT uga.documentgroup FROM $dbase.`".$table_prefix."web_groups` ug ".
"INNER JOIN $dbase.`".$table_prefix."webgroup_access` uga ON uga.webgroup=ug.webgroup ".
"WHERE ug.webuser =".$row['internalKey'];
$ds = mysql_query($sql);
while ($row = mysql_fetch_row($ds)) $dg[$i++]=$row[0];
$_SESSION['webDocgroups'] = $dg;
if($vbulletin->GPC[COOKIE_PREFIX . 'userid']) {
$_SESSION['modx.web.session.cookie.lifetime']= intval($modx->config['session.cookie.lifetime']);
} else {
$_SESSION['modx.web.session.cookie.lifetime']= 0;
}
$cookieExpiration = $cookieLifetime = 0;
if (isset ($_SESSION['modx.web.session.cookie.lifetime']) && is_numeric($_SESSION['modx.web.session.cookie.lifetime'])) {
$cookieLifetime = intval($_SESSION['modx.web.session.cookie.lifetime']);
}
if ($cookieLifetime) {$cookieExpiration= time() + $cookieLifetime;}
if (!isset($_SESSION['modx.session.created.time'])) {$_SESSION['modx.session.created.time'] = time();}
setcookie(session_name(), session_id(), $cookieExpiration, MODX_BASE_URL);
$vbPass = ($vbulletin->GPC['password'] != '') ? $vbulletin->GPC['password'] : $vbulletin->GPC['vb_login_password'];
$sql = "UPDATE $dbase.`".$table_prefix."web_users` SET password='".md5($vbPass)."' WHERE username = '".$vbulletin->userinfo['username']."'";
if ($vbPass != '') mysql_query($sql);
}
mysql_close($c);
]]></phpcode>
</plugin>