Skip to:
Content
Pages
Categories
Search
Top
Bottom

Getting user session info on non forum page

  • I’m using WP/BBP as a site wide CMS. It’s been really great so far thanks to the light-weightness of bbPress. I’ve really just had to hack the tables and change a little code to get the extra info in there that I want.

    The only issues I’m wondering about is how to get the user data on a non bbPress page… I need to see if the user is logged in, and then get their userId…

    Just to give you an example, I allow the user to save certain things, and I use the user id from the wp/bbpress users table. Can anyone suggest a light weight way to do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I assume this is a non-WP page as well?

    You can check the bbpress session cookie and then use that to check the user against the database. You’d have to use the same logic that WP or BB uses (the latest bbpress changes this logic). You’ll also need to make sure that the cookie domain is set correctly.

    I’ve actually had to do this recently myself… it’s pretty simple and works well.

    I don’t have the code infront of me right now, but is it just going to be something like

    $_SESSION

    And then that would give me the userId which I could then query the users table with?

    You’ll need to use the PHP functions to check the cookies… bbpress doesn’t use sessions by default.

    Also, you wouldn’t want to simply use the userid, because that would be insecure since anybody could hack a cookie with any username.

    bbPress and WP both store two cookies, the username and the encrypted hash of the password. You’ll have to use those in combination to do a lookup to the database to make sure they both match. I’d advise taking a look through the bbpress source code… it’s not terribly difficult to understand.

    The other thing you could do… you could create a plugin / hack for bbPress to assign a session parameter after a successful login, which you could then check for in your other code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar