rss

Mar
22

Common Login for phpBB3 and WordPress

Posted (Amit) in PHP on 22-03-2008

18

I was just working on a site where i have to integrate phpBB3 and wordpress, i tried searching for things on internet but was not able to find a simple and feasible solution for the problem, so i thought of diving into the code and get things working on my own, and wow i got success. Here are the function that you should call to start a phpBB and WordPress session.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function authenticateForumAdmin($username, $pass)
{
 global $dbObject, $user, $auth, $db;
 
 $loginDetails = $auth->login($username, $pass, false, 1, 1);
 
 if($loginDetails["error_msg"] != "")
 {
     return false;
 }else{
     return true;
 }
}
 
 
 
function wp_authentication($username, $pass)
{
 global $_POST, $_COOKIE;
 
 if (function_exists('get_userdatabylogin')) {
     $user = get_userdatabylogin($username);
 
     if (! $user or $username != $user->user_login) {
	 if ((bool) get_option('http_authentication_auto_create_user')) {
	     // Create user and re-read from database for login (next step)
	     $this->create_user($username);
	     $user = get_userdatabylogin($username);
	 }
	 else {
	     // User is not in the WordPress database, and thus not authorized
	     die("User $username does not exist in the WordPress database");
	 }
     }
 
     // Login the user by feeding WordPress a double-MD5 hash
     $password = md5($user->user_pass);
 
     // User is now authorized; force WordPress to use the generated password
     $using_cookie = true;
     wp_setcookie($user->user_login, $password, $using_cookie);
 }
 else {
     die("Could not load user data");
 }
}

I am still looking for a single sign-on solution for phpBB3 and WordPress. Will post here once i am done with it.

Share

Comments (18)

Thanks for this Amit!

Do you know if it works with phpbb3 and wordpress 2.7? Also, did you find a single sign on solution?

Amit

I haven’t tested the code for phpbb3 and wordpress2.7 but the code above is working for lower version of phpbb3 and wordpress 2.6.

hello, thanks for this, but how can i install it? thx.

Amit

Yes, you can create an auth class and call these functions in it so that both the WordPress and phpBB sessions are authenticated and created.

i am a complete noob, can you please write a guide on how to install this? i am very interested in using this and installing it

Amit

Hey Abdullah, i will definitely write a guide for installing it soon.

I’m very interested too !!! :)

Hi amit,

Thanks u very much .
but still i’m unable to use this code.
i want to use common login phpbb3, wp 2.7 and my site as welll
plz help us how can i do it.

Thanks
DRSEERVI

Dear Amit, I am also waiting on the guide. Can you please E-mail me the guide at samisgod@gmail.com upon completion. Thank You

Amit

Hey you all, the code i provided is enough to get a common login for phpBB nd wordpress. I have used the same code for my project and its working. Please let me know what is the exact problem that you guys are facing.

Sorry for late reply, kinda busy with my projects. Thanks.

how we can do it? Can you explain it step by step please?

Amit i have tried for this but it is not working for wordpress2.7 and phpbb3.0.5. Do you have any updated solution for this

Amit

I haven’t done this very recently. Can you tell me whats the problem u r facing, meanwhile let me try this again.

Hi all,

Just after your latest message was postes, on June, 12, 2009, a new WordPress United was issued. I was also trying to develop the same thing and didn’t pay attention. However, after having written a system that nearly works, I discovered that new WPU and tried it on a test forum/blog : it works a breeze !

So I’ll install it and it seems to solve near everything without going too deep under the code…

In a few days, I’ll implement it on my Hoshikaze 2250 site and you’ll see what it does.

@+

BenoĆ®t ‘Mutos’ ROBIN
Hoshikaze 2250 Project

Can you provide how to execute the code

Hello Amit,
I am noob in phpbb. I want to make a webservice for login authentication in phpbb3 and call from asp.net application. By single click to a link in asp application and go to php bb without login in it.

Please help me.

Thanks with Regards’
Jitendra

Amit

Hi Jitendra,
I am not in touch with the new phpbb login functionality but anyway here is my suggestion. On the phpbb login file there would be some functions that helps user logging in. Then using these functions create a separate PHP page. Pass the username and password(encrypted) to this page and return true or false as a response. Hope that gives you a hint. Let me know if you are still confused, i would try to get more details about that.

Hello all! I like this forum, i set up many gripping people on this forum.!!!

Large Community, respect all!

Post a comment



Amit Yadav is Stephen Fry proof thanks to caching by WP Super Cache