Skip to:
Content
Pages
Categories
Search
Top
Bottom

Do we know where our members are?

  • Well do we? Each page sets it’s location (bb_location), but is this location saved for each user visiting this page? I want to use this so I can see who is at what page (with something like: select user where bb_loaction = frontpage) and generate a list of all users currently at the frontpage.

    If this is not the case, is it possible (using a plugin) to save this info for every user? And how?

    Greetz Null

    ps: it would be cool if when a user leaves the site, the location would be set to -none- or something. Perhaps this can be done when the session of this user is over?

Viewing 11 replies - 1 through 11 (of 11 total)

  • _ck_
    Participant

    @_ck_

    bb_location is not called by default but still is typically used on every page. It’s easier to track the request_uri and store it with the title (formal name) of the page since bb_location does not track all pages (ie. edit and topic pages are the same, all views are the same, etc). My User Track plugin does this but it’s not available to the public yet.

    bbPress does not use sessions by default (because they slow the system). But there is no need to use them, you can assume after 30 minutes since the last page load the user has left the site. Most tracking plugins work like that.

    update: here you go:

    https://bbpress.org/plugins/topic/mini-track/

    Yeah about that plugin of yours, hurry up with it, many people want that one :):)

    I can also test it if you like on my board

    But back on topic: lets say I want to use bb_location since I ONLY want to track users on the frontpage. Is this possible without extending the users table?

    If a user goes to another page or leaves the bb_location will change. Thats not a problem since I only want the people from the frontpage.

    And how would you update this? At page load or something? Perhaps I should request this in the plugin section since I have no idea how to make a clean plugin of this…


    _ck_
    Participant

    @_ck_

    If you know some basic PHP this is a very easy thing to store/track but you’ll need some more extensive code to print it out.

    Essentially what you’d want to do is store in the usermeta the bb_location and timestamp on every load of bbpress via a simple plugin.

    Then to count the number of users in the front page you’d do a mysql query to limit by time and count the number of “front-page” that appear.

    I’ll give you some rough code in a minute, it’s fairly straightforward.


    _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

    Thanks for the big reply. I think I’ll wait untill you release your usertrack plugin and hook into that. Then I can simply use somthing like: select username where location = frontpage and put it in a foreach or something (assuming your plugin keeps a record of where people are)

    Solves all my problems.

    Thanks again


    _ck_
    Participant

    @_ck_

    Okay it was too easy so I gave in and did it for you.

    https://bbpress.org/plugins/topic/mini-track/

    Darn and you did this out of the blue? Respect!

    Thanks going to try it, will report back later!


    _ck_
    Participant

    @_ck_

    Save it again and re-upload, I just radically improved it.

    Now will give a list of names with mini_track(2) and has a status page with the complete list for admin site-url.com/?mini_track_display

    The status page will auto-refresh every 30 seconds.

    This plugin uses a very bad approach for busy websites but should be okay for sites that have no more than a couple dozen people online at once.

    Okay, I’ve tested the new one. I see there is a hyperlink now and when you click it, I see this (statuspage?):

    There are 1 total users online. 1 of them are members: Admin. 1 of them are on this page.

    Admin (1) - 1 minutes ago - /mssp/?mini_track_display

    The last part /mssp/etc is a link too? I think this is a bug.

    Sec:

    Is this also possible?

    These members are currently on this page: jhon, kim, jack, etc

    Third: It would be cool if the names are clickable and you go to their profile while clicking them.


    _ck_
    Participant

    @_ck_

    If you look at the instructions, you can get a list of names by using <?php mini_track(2); ?> instead of (1)

    I’ve updated the code to link to profiles.

    That’s all I’m doing on that plugin, if you want more, you need to learn PHP.

    Ah thanks, you did more than enough, thanks again!

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