Advertisement
BakerMan

This Month or Later Only, Please! (TEC 2.0.10)

Dec 6th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. // Don't allow anything earlier than this month to be displayed in the gridview
  2. if (isset($eventDate) and isset($eventDisplay) and $eventDisplay === 'month') {
  3.     $thisMonth = date('Y-m').'-01';
  4.     $redirectTo = get_site_url();
  5.  
  6.     // Is the user requesting something earlier than this month?
  7.     if ($eventDate < $thisMonth) {
  8.         // Redirect if possible
  9.         if (!headers_sent()) {
  10.             header("Location: $redirectTo");
  11.             exit();
  12.         }
  13.         // If not possible to redirect, show an error message or 404
  14.         else {
  15.             get_template_part('404');
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement