Greetings!
I’ve used punbb along with another piece of software (sitelok). First you would have to decide which database will be the primary database. I chose the sitelok database to be the one controlling the logins, and then modified the sitelok login script to log in the user to punbb. Also in that modification, I did a lookup on the user in punbb… if they weren’t there, I inserted them into the punbb database. I’m not sure this is an optimal solution, maybe there’s a better way, using WP as the primary database. Anybody out there have suggestions? FYI, I posted the code I used in sitelok, below.
Emily
// EKB Add login to punbb
// Feb 11 2007
define('PUN_ROOT', '/path/to/punbb/');
require PUN_ROOT.'include/common.php';
// Load the login.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
$form_username = $_POST['username'];
$form_password = $_POST['password'];
$username_sql = ($db_type == 'mysql' || $db_type == 'mysqli') ? 'username=\''.$db->escape($form_username).'\'' : 'LOWER(username)=LOWER(\''.$db->escape($form_username).'\')';
$result = $db->query('SELECT id, group_id, password, save_pass FROM '.$db->prefix.'users WHERE '.$username_sql) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
list($user_id, $group_id, $db_password_hash, $save_pass) = $db->fetch_row($result);
$authorized = false;
if (!empty($db_password_hash))
{
$authorized = true;
$form_password_hash = pun_hash($form_password);
} // end if we found a user record
// if we don't find the person, assume they just haven't been in the forum yet.
// Insert them into the database... using the same user info as sitelok
if (!$authorized) {
$sql = 'INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($form_username).'\', 4, \''.pun_hash($form_password).'\', \''.$Email.'\', 2, 1, -5, \''.$db->escape($pun_config['o_default_lang']).'\', \''.$pun_config['o_default_style'].'\', '.time().', \''.get_remote_address().'\', '.time().')';
$result = $db->query($sql) or error('Unable to insert user into punbb', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT id, group_id, password, save_pass FROM '.$db->prefix.'users WHERE '.$username_sql) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
list($user_id, $group_id, $form_password_hash, $save_pass) = $db->fetch_row($result);
} // end if not authorized
// Update the status if this is the first time the user logged in
if ($group_id == PUN_UNVERIFIED)
$db->query('UPDATE '.$db->prefix.'users SET group_id='.$pun_config['o_default_user_group'].' WHERE id='.$user_id) or error('Unable to update user status', __FILE__, __LINE__, $db->error());
// Remove this users guest entry from the online list
$db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape(get_remote_address()).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
$expire = ($save_pass == '1') ? time() + 31536000 : 0;
pun_setcookie($user_id, $form_password_hash, $expire);
// end punBB login