Skip to:

whos online widget not working (think it\'s a mysql timezone problem)

  • francescolaffi


    Tried the online widget and it don’t show any user also if there is someone else online. Using wpmu and bp 1.2.1.

    I’ve looked into it a little and found that a user is selected as online if is last activity not more than 5 min before than mysql time, as you can see in this line from bp-core-classes

    if ( 'active' == $type || 'online' == $type )
    $sql['where_active'] = "AND um.meta_key = 'last_activity'";
    if ( 'online' == $type )
    $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()";

    I’ve looked in the db and tried some queries, i think the problem is that the last_activity is UTC and NOW() is UTC+1.

    If I mod the core to check 65 MINUTE it works, but this is only a temporary solution and only valid for this configuration.

    Maybe there’s a stupid solution or setting I haven’t found, but please help me find it. I’m on shared hosting so i can’t change the mysql server clock or timezone.

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

  • francescolaffi


    maybe I found a better solution

    If I’m right bp always set last_activity meta in gmt ( bp_core_record_activity() in bp-core.php use gmdate ) so the query should compare with that timezone, I tried using UTC_TIMESTAMP() instead of NOW() in the query and it’s working.

    If some expert can confirm that this solution is valide not only for my configuration but for everyone I’ll open a ticket.




    frances, where exactly did you do the change? If you could tell me php and line, I can try out if it works for me, too.




    in ” bp-core/bp-core-classes.php” around line 139

    change “NOW()” to “UTC_TIMESTAMP()”

    Don’t know if it’s a good solution but it works




    Thanks for the info, but as you mentioned maybe not the best solution. What about updates?

    Could this be called from a bp-custom.php? And if so how?

    Or is this bug fixed in the next BP version?




    I forgot to add this topic to my favorites so I didn’t read your replies.

    I opened a ticked in the trac , if this solution is working for you could write there that you successfully tested and solution will be probably included in future bp release. You can login in the trac with the same account you are using for this forum.



    Revising the bp-core/bp-core-classes.php from “NOW()” to “UTC_TIMESTAMP()” worked like a charm!

    Thank you gasparking



    It worked for me, too! Thank you very much!

    Andy Peatling


    Thanks, this is fixed in the 1.2 branch and will be in the next release.

    Using bp1.2.3 and wp2.9.2 and got the same problem too.

    Tried the solution stated here and it woks!

    Many thanks :)

    Same, 1.2.2, didn’t work until I did this. Works perfectly now tho :D

    Vali Hutchison


    I had the same problem and the UTC_TIMESTAMP() fix worked for me too. Be great to have this added to the next BP version

    Already fixed in the 1.2 branch, it will be in the next version.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘whos online widget not working (think it\'s a mysql timezone problem)’ is closed to new replies.
Skip to toolbar