New Zenner
- Join Date:
- Aug 2008
- Posts:
- 47
- Plugin Contributions:
- 0
Integrating PHPBB3 with Zencart
okies as a follow up to my last post...
The code change listed above to includes/classes/class.phpbb.php will not enter the the latest user on your phpbb forums index page.
if you want your Zen Cart users to be displayed on your phpBB forums then edit includes/classes/class.phpbb.php and look for phpbb_create_account
replace that the entire function with the following code.
function phpbb_create_account($nick, $password, $email_address) {
if ($this->phpBB['installed'] != true || !zen_not_null($password) || !zen_not_null($email_address) || !zen_not_null($nick)) return false;
if ($this->phpbb_check_for_duplicate_email($email_address) == 'already_exists') {
// $this->phpbb_change_email($old_email, $email_address);
} else {
$sql = "select max(user_id) as total from " . $this->phpBB['users_table'];
$phpbb_users = $this->db_phpbb->Execute($sql);
$user_id = ($phpbb_users->fields['total'] + 1);
// $sql = "insert into " . $this->phpBB['users_table'] . "
// (user_id, username, user_password, user_email, user_regdate)
// values
// ('" . (int)$user_id . "', '" . $nick . "', '" . md5($password) . "', '" . $email_address . "', '" . time() ."')";
$sql = "insert into " . $this->phpBB['users_table'] . "
( username,username_clean, user_password, user_email, user_regdate, user_passchg, group_id, user_permissions, user_sig, user_occ, user_interests, user_email_hash)
values
( '" . $nick . "','" . $nick . "', '" . md5($password) . "', '" . $email_address . "', '" . time() . "', '" . time(). "', 2, '', '', '', '', '" . crc32(strtolower($email_address)) . strlen($email_address) . "')";
$this->db_phpbb->Execute($sql);
//could do a check here to see if Insert_ID() matches $user_id...
$sql = "SELECT user_id, username, user_colour
FROM " . $this->phpBB['users_table'] . "
WHERE user_type IN ('0', '3')
ORDER BY user_id DESC LIMIT 1";
$phpbb_newest_user = $this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = '" . $phpbb_newest_user->fields['user_id'] . "'
WHERE config_name = 'newest_user_id'";
$this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = '" . $phpbb_newest_user->fields['username'] . "'
WHERE config_name = 'newest_username'";
$this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = '" . $phpbb_newest_user->fields['user_colour'] . "'
WHERE config_name = 'newest_user_colour'";
$this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = config_value + 1
WHERE config_name = 'num_users'";
$this->db_phpbb->Execute($sql);
// @TODO: MySQL5
// $sql = "INSERT INTO " . $this->phpBB['groups_table'] . " (group_name, group_desc, group_single_user, group_moderator)
// VALUES (0, 'Personal User', 1, 0)";
// $this->db_phpbb->Execute($sql);
// $group_id = $this->db_phpbb->Insert_ID();
$sql = "INSERT INTO " . $this->phpBB['user_group_table'] . " (user_id, group_id, user_pending)
VALUES ($user_id, 2, 0)";
$this->db_phpbb->Execute($sql);
//might optionally send an extra email welcoming them to the phpBB forum, reminding them of their nickname?
}
}
that will work. As a reminder, phpbb can be set not to accept the same email. if you are using a test email account in your store account it will not work in phpBB. it does not give any errors, the user simply wont be added.
To test out the system thoroughly, delete the user from your store as well as from your phpbb users.
this will ensure that your not running around in circles with working code...