Support » Plugin: Football Pool » Only display x number of games in the future

  • Resolved Footyfan


    I’ve entered all the fixtures for the full season as I want people to be able to use the site to see all the forthcoming fixtures as well as predict, however I want to restrict how many games/days/weeks into the future they can predict by hiding future games beyond a certain time from NOW.

    Is there a simple update I can make to the code to dynamically hide future games for example, any games more than 2 weeks into the future will not be visible in the submit predictions page?

    Thanks for your help in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author AntoineH


    The plugin has two options build in for this, but neither of them are dynamic, so it would require some action from the admin.

    1. Group matches in match types and only show the ‘current’ match type.
    2. Make a custom prediction form with the fp-predictionform shortcode.

    If it has to be dynamic, you’ll have to do some programming. The pages\class-football-pool-pool-page.php contains a line that reads:

    $result = $matches->get_match_info_for_user( $current_user->ID );

    This method accepts an array of match ids as a second parameter. So if you run a query on the matches table (or use the matches collection) and select only the ids you want, you can add those ids to the method. Example:

    $matches = new Football_Pool_Matches;
    $ids = array( 0 ); // force empty set
    // only matches between now and two weeks from now
    $date_from = time();
    $date_to = strtotime( '+2 week' );
    foreach ( $matches->matches as $match ) {
    	if ( $match['match_timestamp'] >= $date_from  && $match['match_timestamp'] < $date_to ) {
    		$ids[] = $match['nr'];
    $result = $matches->get_match_info_for_user( $current_user->ID, $ids );

    note: if you change the plugin’s code you will have to be careful not to overwrite your changes when you do an update of the plugin.

    Amazing response. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Only display x number of games in the future’ is closed to new replies.