• Resolved elthib7

    (@elthib7)


    Hello
    How to order the players by points in the leaderboard ?
    Because by default they are orderey by ID… how to change that ?
    Regards

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author web-able

    (@web-able)

    They should by ordered by points but BetPress supports only MySQL. Most probably you use another database such as MariaDB and that’s why it is bugged.

    Thread Starter elthib7

    (@elthib7)

    No i’m working with MySQL
    They are ordered by points when the splits are updated ? not automatically ?

    Plugin Author web-able

    (@web-able)

    Hmm strange, they should always be ordered by points.

    What is your exact MySQL version? Also, give me your PHP version, WordPress version and BetPress version. I will set up the same environment and hopefully experience the same problem.

    Thread Starter elthib7

    (@elthib7)

    Where can i see my mysql version ?
    i made a screenshot of my phpmyadmin :
    https://i.gyazo.com/a284814069d5fa378f6fe9e38d6ed8de.png

    my PHP Version is 5.5.38
    my wordpress version : WordPress 4.7.3
    Betpress Lite, the last version

    • This reply was modified 7 years, 11 months ago by elthib7.
    • This reply was modified 7 years, 11 months ago by elthib7.
    Plugin Author web-able

    (@web-able)

    Then how you know that you are not using MariaDB? They don’t differ much from each other.

    How to check depends on your server. If you are on shared hosting using cPanel, then search for “Server Information” link and click it.

    Thread Starter elthib7

    (@elthib7)

    Ah yeah shit this is MariaDB…

    MariaDB Version 10.0

    There is no way to solve the problem ???

    Plugin Author web-able

    (@web-able)

    Not without modifying the code. There are few things that has to be changed and then it has to be tested so I can’t provide you a “quick-fix” to the problem if that’s what you are asking.

    By default WordPress runs on MySQL. I am not aware if they support MariaDB but BetPress does not support it at this stage. Will try to change that in the next release but don’t see it coming soon.

    Thread Starter elthib7

    (@elthib7)

    ok … thanks for the reply

    I have the same problem. Unfortunately I’m not able to change MariaDB engine. My hosting support says that MariaDB is compatible with MySQL, @web-able could you provide more details? What code should be changed?

    Plugin Author web-able

    (@web-able)

    The information that your hosting support is providing you is not 100% correct. MariaDB is not fully compatible with MySQL and you have the real example here. It is just a more advanced query and we can see the result differs.

    The code that should be changed is the query that generates the leaderboard. But most probably you will need some additional PHP code, too – depends on what’s possible in MariaDB. More specifically: betpress_get_leaderboard_details() and betpress_get_active_leaderboard_details() in the functions.php file. You can find their usage using any IDE/text editor.

    • This reply was modified 7 years, 10 months ago by web-able.

    I’ve fixed it by adding array sorting to leaderboard.php:

    
    usort($results, function($a, $b) {
        return $b['points'] <=> $a['points'];
    });
    

    Then I hide the positions using css display:none and add css counter to table-row containers.

    Plugin Author web-able

    (@web-able)

    Good job. That’s the easiest but “hackies” way to do it. Also, it is more costly performance-wise than just making the query compatible both with MySQL and MariaDB.

    If someone in the future will see this topic and apply the same solution as you, just keep in mind it requires php7 and most shared hostings doesn’t support yet. So you would want to just change return $b['points'] <=> $a['points']; to return $b['points'] > $a['points] ? -1 : 1;

    Hello, I can pass the file with the changes because it is not php and I want to have that plugin thanks!!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Order players in leaderboard by points ?’ is closed to new replies.