views:

549

answers:

2

I am trying to integrate my site to use the bbpress/wordpress user system.

All I need is the ability to get the User Name and/or User ID of the person currently on my site. I don't really need any other functionality from bbpress or wordpress on the site.

If I could get the user's ID and then the ability to get the user's name from that ID would be perfect for all of my needs.

Additional Info: My site is ran on PHP5 and MySQL, I have wordpress and bbpress upto date and currently integrated with each other.

+1  A: 

Have you tried just printing out the contents of $_COOKIE? Mine contains the following:

Array
(
    [wordpress_test_cookie] => WP Cookie check
    [wordpress_logged_in_##########] => ceejayoz|#####|##########]
)

Should be simple for you to parse.

foreach($_COOKIE as $key => $value) {
  if(preg_match('@^wordpress_logged_in_@', $key) {
    $cookie = explode('|', $_COOKIE[$key]);
    $username = $cookie[0];
  }
}
ceejayoz
mine has['wordpress_##############################'] => "admin|##########|###############################"
Jayrox
where does the first variable after wordpress_ come from?
Jayrox
Not sure, I'd say create a new user and see if it's different. It may be a per-install hash. If not, step through $_COOKIE with a foreach() loop and look for wordpress_logged_in_*.
ceejayoz
thats what i was thinking
Jayrox
Added code for doing that.
ceejayoz
Thanks, I'll write up a quick function to sanitize the $username from the $cookie[0], then an SQL statement to get the $user_id from the wp_users table.
Jayrox
I was reading all over the web about how the username was double hashed in the cookie. i should have just dumped it in the first place and saw what i had to play with.
Jayrox
A: 

hi guys, Excuse me for asking but where sould i put this code,? And how do i add it? Or could someone tell me how to get to a users BBpress favorites ?

thanks in advance (keep this topic alive?)