Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter fegs1204

    (@fegs1204)

    Thank you Antoine, that was exactly my problem, finally it’s working as expected! Best Regards.

    Thread Starter fegs1204

    (@fegs1204)

    Dear Antoine,
    In the post (https://www.ads-software.com/support/topic/how-to-include-pool-choice-in-registration-form/#post-9947190) @pc1271 says that the code was not working and you got to check it. Then he says that you found out that the solution was to “translate the strings”, I have not been able to get this code to work, maybe i’m missing something regarding the “translation of the strings”?

    Thread Starter fegs1204

    (@fegs1204)

    Hi Antoine, thanks for your prompt answer! This is the link:
    https://www.ads-software.com/support/topic/how-to-include-pool-choice-in-registration-form/
    Best regards!

    @mastermax12 this is how I did it:
    class FootballPoolExtensionMatchPredictions {
    public static function init_extension() {
    if ( ! is_admin() ) {
    add_filter( ‘footballpool_statistics_matchpredictions’, array( __CLASS__, ‘change_matchpredictions’ ), null, 2 );
    }
    }

    public static function change_matchpredictions( $predictions, $match_info ) {

    // add score
    array_walk( $predictions, array( __CLASS__, ‘add_score’ ), $match_info );
    // remove users without predictions
    //$predictions = array_filter( $predictions, array( __CLASS__, ‘remove_inactive_users’ ) );
    // sort by score
    usort( $predictions, array( __CLASS__, ‘sort_table’ ) );

    // remove users from other leagues
    $predictions = array_filter( $predictions, array( __CLASS__, ‘Filter_user_league’ ) );

    return $predictions;
    }

    public static function Filter_user_league ( $p ) {

    $user_id = get_current_user_id();

    if ( $user_id > 0 ) {
    $pool = new Football_Pool_Pool();
    $league_name = $pool->get_league_for_user( $user_id );
    }

    return (int) $p[‘league_id’] === $league_name;
    }

    public static function add_score( &$prediction, $key, $match_info ) {
    $pool = new Football_Pool_Pool;
    $prediction[‘score’] = $pool->calc_score(
    $match_info[‘home_score’],
    $match_info[‘away_score’],
    $prediction[‘home_score’],
    $prediction[‘away_score’],
    $prediction[‘has_joker’],
    null
    );
    }

    public static function remove_inactive_users( $prediction ) {
    return ! is_null( $prediction[‘home_score’] ) && ! is_null( $prediction[‘away_score’] );
    }

    public static function sort_table( $a, $b ) {
    if ( $a[‘score’] == $b[‘score’] ) return 0;
    return ( $a[‘score’] < $b[‘score’] ) ? 1 : -1;
    }

    }

    Best Regards!

    Got it working! Thank you Antonie. Now I’m stuck in the code that was supposed to be the easiest one… filtering the ranking. I’m using the following shortcode:

    [fp-ranking league=”user” num=”50″ date=”now”]

    And it isn’t working… it keeps showing all the registered users.

    Please your comments.

    Thank you very much Antonie! It works perfectly!!

    Now I need to do the same for the bonus questions predictions page. Where should I start from?

    Thank you Antonie,

    I’m trying to find a solution for this but, please, I need your help. I’m thinking that maybe I can work over the extension “football-pool-matchpredictions-order” where you use the function “remove_inactive_users”. I’m trying to add the function filter_users( $users ) which returns the users array for a specific league but, indeed the data structure is different. How does the $prediction parameter work?. For instance you are using this parameter like this: $prediction[‘score’] = $pool->calc_score… Can it be used with the $users array from the mentioned function? Please, If I get this working I will go right away to the donation page ??

    Best Regards!

    Hi,
    Related to this topic, I want to hide users from other leagues in the user’s prediction page. Can the “football-pool-user-selector-own-league-only” extension be adapted to do this? I’m not an expert in php but I can try!

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