Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Do we know where our members are?


_ck_
Participant

@_ck_

Well I started to write some code but I then remembered why I did it completely on my own. There are many problems you encounter with trying to do this efficiently with as few DB queries as possible. Using the built in bbpress functions when there’s only a couple people online are fine, but when it gets to many times that, it’s too inefficient.

There’s also the issue of tracking NON members. Much more tricky than authenticated users.

I recommend you modify simple online list to track position. Much easier.

If you know PHP, here’s the process:

1. take the IP of the current user, change it into ip2long and make that the index of an array or object

2. store the request_url for that index

3. store the time() for that index

4. if they have a user id# (a member) store that

5. save the array via bb_update_option (not usermeta)

6. on every bbpress load, do a bb_get_option for the usertracking, which is the array of all the above

7. comb through the time() for timestamps older than 30 minutes and discard them

8. count the remaining items to see how many online in past 30 minutes

9. comb the request_url to see if it == your bbpress front page and count

Skip to toolbar