It is a frequest request, or probably a need, that when working on large custom applications that involve numerous frameworks (WordPress, bbPress, E-commerce platforms), to have the site as a whole work together in a logical fashion for the user experience.
If the entire site involves different application frameworks, this usually means that these applications have different code bases and different databases which warrants signing into each application..
If true, you will soon see the need to have a single sign-on capability for the entire site. Meaning simply, you sign on one time and don’t need to sign in again to access different parts of the site.
We are currently working on a PHP custom web development application for a client. Since this is a social networking application, the client requested a forum to be added and integrated seamlessly with the custom application.
We are a frequent user of WordPress and now that since a recent review of bbPress, are very confident that the basic forum functionality of bbPress will be a great fit for our clients needs.
Maybe someday we will have the time to wrap this functionality as a plugin, but for now, we kept our bbPress login integration as simple as possible by straight-up coding in the changes. We assume you have already installed bbPress onto your site.
#1 Create bbPress user account with db Insert
What to do: First thing to do is to create a bbPress user in the bbPress database. Unlike other application that need numerous inserts and settings making registering complex, with bbPress, we can take the short cut of creating a bbPress user by inserting a record into the bb_users table that bbPress creates upon install.
You just need a screen name, email and a md5 password, usually from your registration form from the custom application.
You need to take the password and change into a md5 string using md5 function like this:
$pwd = md5($_POST["password"]);
After the user submits the new registration in the custom application and your code creates a new user in your application, you then would take same info and insert into db like:
$sql = "INSERT INTO bb_users ( custom_account_id, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_status, display_name ) VALUES ( '$account_id', '$screen_name', '$m5_password', '$screen_name', '$account_email', '', '$now', '0', '$screen_name' )";
to tie the bb_users table to the custom account table we have for the custom application, we have added a new column to the bb_users table:
custom_account_id int 11
… this way we can perform updates on bb_users with our own account_id.
#2 Create custom bbPress user login page
What to do: There are different ways to accomplish this, but again we went for a simple way since bbPress is on the same server. We created a new file at the forum root and called it login.controller.php. We looked at the bb-login.php at same root to analyze what the code does and what includes and functions it uses to login a user.
This file includes bb-load.php which is a base php file that sets up a lot of includes and global variables needed for the two bbPress function calls we need:
1) bb_login($user_login, $password, $remember_user) and …
2) bb_logout()
We create a header redirect with the user login (our screen name) and password and a mode for login or logout. We send our variables via a GET call. While my example does not encrypt any variables, you can add some extra security measures like encrypting/decrypting and checking referring url, etc.
Download sql and custom php login page: bbpress-new-login.zip
Send comments if you have any questions and I will try to help!
Happy Coding!





How-To's, Tips and Secrets
for
Internet Entrepreneurs