Skip to content

Instantly share code, notes, and snippets.

@jreviews
Created March 8, 2020 21:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jreviews/0653598174ca6e5a7d4affba049d580d to your computer and use it in GitHub Desktop.
Save jreviews/0653598174ca6e5a7d4affba049d580d to your computer and use it in GitHub Desktop.
Close reviews for future events
<?php
defined('MVC_FRAMEWORK') or die;
function close_future_event_reviews($open, $params)
{
$listing = $params['listing'];
$fieldName = 'jr_eventstartdate';
if ( !empty($listing['Field']['pairs'][$fieldName]['value'][0]) && $listing['Field']['pairs'][$fieldName]['value'][0] > date("Y-m-d H:i:s") )
{
return false;
}
return $open;
}
Clickfwd\Hook\Filter::add('listing_user_reviews_open', 'close_future_event_reviews', 10);
@jreviews
Copy link
Author

jreviews commented Mar 8, 2020

The filter allows you to automatically keep reviews closed for future events and open them after the event start date.

To use this filter:

  1. Upload the above file to jreviews_overrides/filters
  2. Add the line below to jreviews_overrides/filter_functions.php, if you are not using filters yet, read the documentation on Getting Started with JReviews developer filters
require_once "close-future-event-reviews.php";
  1. Adjust the fieldname jr_eventstartdate used for the $fieldName variable based on the name of the field you used for the event start date .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment