I run a community site that uses a phpBB2 forum, and I was wondering how to fetch informations from the forum into other pages (without messing with phpBB2 code, which is something I don't want to even hear about)
Here are some tips that may help you make your existing pages and phpBB2 communicate.
phpBB Fetch All
phpBB Fetch All : This project is a collection of functions you can easily use on any pages. Simple installation (5 or 6 pages in a forum sub-directory) and you have ready-to-use functions about posts (last posts, last topics, ongoing thread…), users (top posters, info about a random user…), polls and a lot of things. The doc pages are clear and list every function available.
This package contains almost everything I needed… Almost only, since there is no function to dectect informations from a login cookie, if any. It retrieves infos from the forum, but not from a user currently viewing a page.
Reading phpBB2's cookie
Hopefully, reading the login cookie is not difficult, I was real glad after a short googlage to realize how easy it was :) The following quick example just displays if the user has an ongoing session or cookie in your forums, you'll need to edit only line 5.
- <?php
- // phpBB includes
- define('IN_PHPBB', true);
- // next one is the physical path to your forums root : CUSTOMIZE
- $phpbb_root_path = '/home/user/you/forums/';
- include($phpbb_root_path . 'extension.inc');
- include($phpbb_root_path . 'common.'.$phpEx);
- // Start session
- $userdata = session_pagestart($user_ip, PAGE_INDEX);
- init_userprefs($userdata);
- // From now on, we have user infos
- if ($userdata['session_logged_in']) {
- echo "You are : ".$userdata['username'] ." (".$userdata['user_email'].")<br>\n";
- echo "Userid : ".$userdata['user_id']."<br>\n";
- } else {
- echo "Not logged !";
- }
- ?>
The informations fetched can be any $userdata[thing] where thing is a field from phpbb2_users table : user_id, username, user_regdate, user_password, user_email, etc …
You can now use this informations into your existing site, for example auto-fill the comments form fields with username, user_url and user_email.
Shorter URL
Want to share or tweet this post? Please use this short URL: http://ozh.in/1j
Nice hints :)
But let's recognize Invision is much better :)
Integrating phpBB with WordPress
My prayers have been answered!
For quite a while now, I have been trying to figure out how to integrate phpBB with WordPress. I have known and used the phpbb_fetch_all mod for quite a while, but I had not figured out how to handle merging the two c…
How did you work around both applications having funcs named get_userdata()?
The easiest way is to rename fetch_all's func to something else, like prefix them with "fa_" (this is quite quick as there arent so many functions)
It has more features for sure, but it also costs a lot more. I don't think it's fair to look at these things from a simple this one is better than that one standpoint. The right tool for the job, in other words. It's also important to note that phpBB 3.0 is bringing many new features to the table.
>
I'm trying to implement this as you say and have done so with all of my fetch_all functions. But it seems as if the same fix is required throughout all of phpbb (not just phpbb fetch all). Does that make sense? I'm a little nervous to make those changes, because I don't want to mess with my boards, but it would be great to integrate the boards with my WordPress.
Thanks!
Sam
Why would you need to modify original phpBB functions ? fetch_all functions retrieve stuff from the phpbb tables, no matter their name is do_something or fa_do_something …
I'm getting this error
Fatal error: Cannot redeclare get_userdata() (previously declared in /home/content/m/y/s/mysportsradio/html/wp-includes/functions.php:184) in /home/content/m/y/s/mysportsradio/html/boards/includes/functions.php on line 116
I think may have something to do with common.php here:
include_once ($phpbb_root_path . 'common.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
I'm very novice at php so I'm pulling my hair out but want to get this solved. Thanks for your help!
Yes, that's why you have to rename fetch_all's functions. But leave those in phpbb intact.
>
This is what I have intended to do, yet I get this error. As mentioned, I'm a newb so I'm not at all clear what's going on with this.
Ok, I have fooled with this again and again. The only place that get_userdata is being called is within wordpress and within phpbb. Fetch all does not have a get_userdata. The conflict is between wordpress and phpbb. The only way you could have managed to make this work is renaming the functions in wordpress. Is that the case?
After changing the wordpress function names, I get this error when trying to call common.php
Call to a member function on a non-object
Any ideas?
If you're interested in logging in users to both your site and phpBB (if you have your own login code and want to have a single-sign-on), then look no further!
I wrote a PHP class to take care of this:
http://www.phpclasses.org/browse/package/1532.html
Like WDuluoz, I also cannot find any get_userdata vars to change in the phpBB Fetch All functions. The variable is within phpBB itself. How did you get around this?
I'm getting the following warning at the top of the page when I use this code. Any ideas on fixing it?
Warning: Cannot modify header information – headers already sent by (output started at /home/path/roster.php:9) in /home/path/sessions.php on line 258
Warning: Cannot modify header information – headers already sent by (output started at /home/path/roster.php:9) in /home/path/sessions.php on line 259
you badly edited roster.php and it's outputting white spaces before sending the header. Probably blank spaces or lines before or after PHP tags.
Sorry, but I'm still not sure what I need to fix.
One of your files is beginning or ending with spaces or new lines. Remove them.
I deleted " Title " and just started with "
That last comment didn't work. I deleted the HTML, HEAD, and TITLE opening and closing tags and just started with the php tag and it got rid of the error.
Thanks.
Hello,
Greetings! I am trying to integrate PhpbBB script with a HTML page. How can i do it? I look forward to hear a earlier reply. Thank you very much for your time.
Good regards.
To the whole world » I loathe PHPBB2 and I ditched it months ago. Ask for support on phpbb2 sites, thanks :)
Yeah, just thought I would leave a comment.
I've used both IPB and phpBB, but the website I am updating is in a phpBB database…I'm finding myself pretty much re-writing the entire forums!
Once I'm done it might be real nice to see since I'm implementing tons of ajax.
Abnormal program termination.
Good site :) Respect for admin…