WordPress.org

Ready to get started?Download WordPress

Forums

Football Pool
[resolved] Only display x number of games in the future (3 posts)

  1. Footyfan
    Member
    Posted 11 months ago #

    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.

    http://wordpress.org/plugins/football-pool/

  2. AntoineH
    Member
    Plugin Author

    Posted 11 months ago #

    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.

  3. Footyfan
    Member
    Posted 11 months ago #

    Amazing response. Thank you.

Reply

You must log in to post.

About this Plugin

About this Topic