Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
myBB Login via Wordpress
#1
Question 
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);
			$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			return $conn;
		} catch(PDOException $e) {
			echo "Connection failed: " . $e->getMessage();
			exit();
		}
	}
	
	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);
			$stmt->execute();
		} catch (PDOException $e) {
			//echo $e->getMessage() . "<br>";
			$stmt->debugDumpParams();
		}
		return $stmt->fetch();
		//print_r($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";
		//print_r($userVars);
		
		setcookie("mybbuser",$cookieValue,0,"/",".forum.greenhell-gaming.de");
		setcookie("mybbuser",$cookieValue,0,"/",".greenhell-gaming.de");
		
	}
	add_action('wp_login', 'autoLogin_myBB', 10, 2);
	#endregion ForumLogin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)