Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
myBB Login via Wordpress
Hey there!
I have a Community with an Wordpress Homepage and using BBpress as Forum. But for us it have to less features.
So I decided to make an new Forum with myBB. But the Users should register or login 2 times.
So started to wrote an Script which Exported all Users from Wordpress-DB to myBB-DB it worked and got alot of informations but I stucked with exporting the password of the User.

So I looked through myBB Code and saw that myBB is setting an Cookie to "login" an user. Now if the User log's in into our Homepage on Wordpress he is automatically loggedin on myBB.
But I'm not sure about "security issues" or something like that.

Thats why I'm asking, Is that okay?

(I'm still syncing all WP Users to myBB but generating an random password, so account on myBB is still password protected)

My WP-snipped for the myBB-Login
	#region ForumLogin
	function newConnection($dbhost, $dbname, $dbuser, $dbpwd) {
		try {
			$conn = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpwd);
			return $conn;
		} catch(PDOException $e) {
			echo "Connection failed: " . $e->getMessage();
	function getMyBBlogin($user_name) {
		$DB = newConnection('localhost:3306', 'xXx', 'xXx', 'xXx');
		$query = "
			Select uid, loginkey, username
			From mybb_Users
			Where username = '$user_name'
		try {
			$sql = $query;
			$stmt = $DB->prepare($sql);
		} catch (PDOException $e) {
			//echo $e->getMessage() . "<br>";
		return $stmt->fetch();
	function autoLogin_myBB($user_name, $user_object) {
		$userVars = getMyBBlogin($user_name);
		$uid = $userVars["uid"];
		$loginkey = $userVars["loginkey"];
		$cookieValue = $uid."_".$loginkey;
		//echo "<pre>$cookieValue";
	add_action('wp_login', 'autoLogin_myBB', 10, 2);
	#endregion ForumLogin

Forum Jump:

Users browsing this thread: 1 Guest(s)