Skip to content
GravityKit
Buy
Sign in
0 items
  • Plugins

    GravityKit All Access

    Our complete Kit of essential tools for extending and enhancing Gravity Formsโ€”everything you need to build powerful web apps and workflows.

    Learn more
    • GravityView

      GravityView

      Bestseller

      Display Gravity Forms entries on the front-end of your site and build powerful web applications.

    • GravityImport

      GravityImport

      Trending

      Import entries from CSV files into Gravity Forms to transfer data, create new forms, or update existing entries.

    • GravityEdit

      GravityEdit

      Quickly edit Gravity Forms entries inline to save time, reduce clicks, and streamline your workflow.

    • GravityCharts

      GravityCharts

      Trending

      Turn Gravity Forms entries into interactive charts and graphs.

    • GravityActions

      GravityActions

      Update multiple Gravity Forms entries at once, send bulk emails, and streamline your workflow.

    • GravityCalendar

      GravityCalendar

      Turn Gravity Forms entries into dynamic calendars to showcase events, schedules, appointments, and more.

    • GravityExport

      GravityExport

      Export Gravity Forms entries to Excel, CSV, or PDF and share them instantly with secure download links.

    • GravityMath

      GravityMath

      Perform advanced calculations on Gravity Forms entries to display totals, averages, or build custom calculators.

    • GravityRevisions

      GravityRevisions

      Track, compare, and restore changes made to Gravity Forms forms and entries with a full version history.

    • GravityMigrate

      GravityMigrate

      Migrate all Gravity Forms data, including forms, entries, Views, feeds, uploads, and more.

    • GravityBoard

      GravityBoard

      Manage projects with collaborative project management. Coordinate with your team and streamline your workflows.

  • Ideal For

    • Nonprofits
    • Startups
    • Education
    • Web Agencies
    • Developers
    • Government iconGovernment
    Explore All Use Cases

    Case studies

    • West Fork Schools
    • Princeton University
    • BrightLeaf Giving
    • Jacksonville Port Authority
    • National Severe Storms Lab
    • Leadpal
    • Mediebruket
    • Dragonfly
    View All Case Studies
  • Resources

    • Blog
    • Case studies
    • Support
    • Live Demos
    • Documentation
    • Developer docs
    • GravityKit Academy
    • GravityKit Live!

    Ultimate guides

    • How to use Gravity Forms
    • Editing Gravity Forms entries
    • Importing Gravity Forms entries
    • Exporting Gravity Forms entries
    • Displaying Gravity Forms entries
    • Gravity Forms conditional logic
    • Gravity Forms calculations
    View More Articles
  • Plugins

    • GravityView

      GravityView

      Bestseller

      Display Gravity Forms entries on the front-end of your site and build powerful web applications.

    • GravityImport

      GravityImport

      Trending

      Import entries from CSV files into Gravity Forms to transfer data, create new forms, or update existing entries.

    • GravityEdit

      GravityEdit

      Quickly edit Gravity Forms entries inline to save time, reduce clicks, and streamline your workflow.

    • GravityCharts

      GravityCharts

      Trending

      Turn Gravity Forms entries into interactive charts and graphs.

    • GravityActions

      GravityActions

      Update multiple Gravity Forms entries at once, send bulk emails, and streamline your workflow.

    • GravityCalendar

      GravityCalendar

      Turn Gravity Forms entries into dynamic calendars to showcase events, schedules, appointments, and more.

    • GravityExport

      GravityExport

      Export Gravity Forms entries to Excel, CSV, or PDF and share them instantly with secure download links.

    • GravityMath

      GravityMath

      Perform advanced calculations on Gravity Forms entries to display totals, averages, or build custom calculators.

    • GravityRevisions

      GravityRevisions

      Track, compare, and restore changes made to Gravity Forms forms and entries with a full version history.

    • GravityMigrate

      GravityMigrate

      Migrate all Gravity Forms data, including forms, entries, Views, feeds, uploads, and more.

    • GravityBoard

      GravityBoard

      Manage projects with collaborative project management. Coordinate with your team and streamline your workflows.

    GravityKit All Access

    Our complete Kit of essential tools for extending and enhancing Gravity Formsโ€”everything you need to build powerful web apps and workflows.

    Learn more
  • Ideal For

    • Nonprofits
    • Startups
    • Education
    • Web Agencies
    • Developers
    • Government iconGovernment
    Explore All Use Cases

    Case studies

    • West Fork Schools
    • Princeton University
    • BrightLeaf Giving
    • Jacksonville Port Authority
    • National Severe Storms Lab
    • Leadpal
    • Mediebruket
    • Dragonfly
    View All Case Studies

    How to build...

    • Property Management
    • Product Catalog
    • Fundraising Dashboard
    • Real Estate Directory
    • Document Library
    • Academic Journal
    • Volunteer Management
    • Meal Tracker
    View All Guides
  • Resources

    • Blog
    • Case studies
    • Support
    • Live Demos
    • Documentation
    • Developer docs
    • GravityKit Academy
    • GravityKit Live!

    ultimate guides

    • How to use Gravity Forms
    • Editing Gravity Forms entries
    • Importing Gravity Forms entries
    • Exporting Gravity Forms entries
    • Displaying Gravity Forms entries
    • Gravity Forms conditional logic
    • Gravity Forms calculations
    View More Articles
  • Pricing
  • About
0 items
Results appear automatically as you type.
Loading results…

results found matching

    Sign in
    Buy

    Docs

    • Docs Home

    Gravity Forms Add-Ons

    • GravityView
    • GravityActions
    • GravityBoard
    • GravityCalendar
    • GravityCharts
    • GravityEdit
    • GravityExport
    • GravityImport
    • GravityMath
    • GravityMigrate
    • GravityRevisions
    • GF Widget for Elementor
    • GF Dynamic Lookup
    • GF Entry Tags
    • GF Event Field
    • GF Zero Spam
    • GravityExport Lite

    GravityView

    • Getting Started
    • View Setup
    • FAQ
    • Pre-Sale
    • Advanced
    • Common Problems
    • Customizing Your Views
    • Edit Entry
    • Entry Approval
    • Filter and Sort Results
    • Gravity Forms
    • Merge Tags
    • Roles and Capabilities
    • Search
    • Shortcodes
    • View Settings
    • WordPress Posts

    General Help

    • Account, Invoices, and Billing
    • License Related
    • Plugins and Settings
    • Contact
    • Docs Home
    • Gravity Forms Add-Ons

      • GravityView
      • GravityActions
      • GravityBoard
      • GravityCalendar
      • GravityCharts
      • GravityEdit
      • GravityExport
      • GravityImport
      • GravityMath
      • GravityMigrate
      • GravityRevisions
      • GF Widget for Elementor
      • GF Dynamic Lookup
      • GF Entry Tags
      • GF Event Field
      • GF Zero Spam
      • GravityExport Lite
    • GravityView

      • Getting Started
      • View Setup
      • FAQ
      • Pre-Sale
      • Advanced
      • Common Problems
      • Customizing Your Views
      • Edit Entry
      • Entry Approval
      • Filter and Sort Results
      • Gravity Forms
      • Merge Tags
      • Roles and Capabilities
      • Search
      • Shortcodes
      • View Settings
      • WordPress Posts
    • General Help

      • Account, Invoices, and Billing
      • License Related
      • Plugins and Settings
    • Contact

    GravityCalendar

    • Add a GravityCalendar to Apple Calendar
    • Add a GravityCalendar to Google Calendar
    • Adding custom CSS to your Views
    • Attaching an event into a notification
    • Calendar Blocks
    • Calendar Setting: “No Current Events Behavior”
    • Calendar Shortcodes
    • Calendar: Developer Hooks
    • Can I book an appointment with GravityCalendar?
    • Creating recurring events in Gravity Forms
    • Displaying a calendar
    • Displaying events from another calendar with GravityCalendar
    • Event Field events are showing as all-day in GravityCalendar
    • Getting Started with GravityCalendar
    • GravityCalendar – Customizing event colors
    • How can I change the day weeks start on in Calendar?
    • How to download or subscribe to just one single event
    • How to enable repeating events
    • How to process shortcodes contained within fields used by the Calendar
    • How to remove the all-day text in the calendar list layout
    • I can’t see GravityCalendar settings or create a calendar
    • My calendar or events arenโ€™t displaying
    • Pre-selecting a calendar date using URL parameters
    • The difference between subscribing to a calendar and downloading calendar events
    • Working with timezones in GravityCalendar
    • Home
    • Docs
    • GravityCalendar
    • Pre-selecting a calendar date using URL parameters

    Pre-selecting a calendar date using URL parameters

    Estimated reading: 8 minutes

    Updated on April 24, 2026

    Learn how to automatically navigate to a specific date when someone visits your calendar by adding a URL parameter.

    What you’ll learn #

    This guide shows you how to add a code snippet that allows you to pre-select a date on your GravityCalendar using a URL parameter. This is useful for sharing links to specific events or dates.

    Before you begin #

    • You need GravityCalendar installed and activated
    • You should have at least one calendar feed configured

    How it works #

    When someone visits a URL like https://example.com/events/?calendar_date=2025-03-15 ย , the calendar will automatically open to March 15, 2025.

    Installation #

    1. Copy the snippet
    2. Add it to your site
    /**
     * GravityCalendar - URL Parameter Initial Date Support
     *
     * This snippet allows users to pre-select a calendar date via URL parameter.
     *
     * Usage Examples:
     * - ?calendar_date=2025-03-01
     * - ?calendar_date=2025-03-15
     * - ?calendar_date=2025-12-25
     */
    
    /**
     * The URL parameter name to use for the initial date.
     *
     * Example: If set to 'calendar_date', use ?calendar_date=2025-03-01 in the URL
     * Example: If set to 'start_date', use ?start_date=2025-03-01 in the URL
     */
    define( 'GRAVITYCALENDAR_DATE_URL_PARAM', 'calendar_date' );
    
    add_filter( 'gravityview/calendar/options', 'gravitycalendar_add_initial_date_from_url', 10, 3 );
    add_filter( 'gravityview/calendar/extra_options', 'gravitycalendar_set_navigate_to_current_from_url', 10, 3 );
    
    /**
     * Get and validate date from URL parameter.
     *
     * This helper function extracts the date from the URL, validates the format,
     * and ensures it's a real date. Returns the validated date string or false.
     *
     * @since TBD
     *
     * @return string|false The validated date string (YYYY-MM-DD) or false if invalid/missing.
     */
    function gravitycalendar_get_date_from_url() {
    
    	/**
    	 * Check if the URL has our date parameter.
    	 */
    	$url_param_name = GRAVITYCALENDAR_DATE_URL_PARAM;
    
    	// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading URL parameter for display only.
    	if ( ! isset( $_GET[ $url_param_name ] ) ) {
    		return false;
    	}
    
    	/**
    	 * Get the date from the URL and clean it up for security.
    	 */
    	// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading URL parameter for display only.
    	$user_provided_date = sanitize_text_field( wp_unslash( $_GET[ $url_param_name ] ) );
    
    	/**
    	 * Check if the date format is correct (YYYY-MM-DD).
    	 *
    	 * Example: '2025-03-01' is valid, '03/01/2025' is not.
    	 */
    	$is_valid_format = preg_match( '/^\d{4}-\d{2}-\d{2}$/', $user_provided_date );
    
    	if ( ! $is_valid_format ) {
    		GV_Extension_Calendar_Feed::logger()->error(
    			sprintf(
    				'Invalid date format in URL parameter "%s". Expected YYYY-MM-DD, got: %s',
    				$url_param_name,
    				$user_provided_date
    			)
    		);
    
    		return false;
    	}
    
    	/**
    	 * Check if the date is actually real.
    	 *
    	 * Example: '2025-03-01' is real, '2025-13-45' is not (no 13th month or 45th day).
    	 */
    	list( $year, $month, $day ) = explode( '-', $user_provided_date );
    
    	$is_real_date = checkdate( (int) $month, (int) $day, (int) $year );
    
    	if ( ! $is_real_date ) {
    		GV_Extension_Calendar_Feed::logger()->error(
    			sprintf(
    				'Invalid date in URL parameter "%s": %s (this date does not exist)',
    				$url_param_name,
    				$user_provided_date
    			)
    		);
    
    		return false;
    	}
    
    	return $user_provided_date;
    }
    
    /**
     * Add initialDate to calendar options based on URL parameter.
     *
     * This function checks if a date is provided in the URL and, if valid,
     * sets it as the initial date for the calendar to display.
     *
     * @since TBD
     *
     * @param array $calendar_options The calendar configuration options passed to FullCalendar.
     * @param int   $form_id          The form ID.
     * @param int   $feed_id          The calendar feed ID.
     *
     * @return array Modified calendar options with initialDate if valid URL parameter exists.
     */
    function gravitycalendar_add_initial_date_from_url( $calendar_options, $form_id, $feed_id ) {
    
    	$date = gravitycalendar_get_date_from_url();
    
    	if ( false === $date ) {
    		return $calendar_options;
    	}
    
    	$calendar_options['initialDate'] = $date;
    
    	return $calendar_options;
    }
    
    /**
     * Set navigateToEvents to "current" when URL date parameter is present.
     *
     * When a user provides a specific date in the URL, we want the calendar to stay
     * on that date rather than automatically navigating to past or future events.
     * This overrides the "No Current Events Behavior" setting to "Stay on Today".
     *
     * @since TBD
     *
     * @param array $extra_options Extra calendar options (not standard FullCalendar options).
     * @param int   $form_id       The form ID.
     * @param int   $feed_id       The calendar feed ID.
     *
     * @return array Modified extra options with navigateToEvents set to 'current'.
     */
    function gravitycalendar_set_navigate_to_current_from_url( $extra_options, $form_id, $feed_id ) {
    
    	$date = gravitycalendar_get_date_from_url();
    
    	if ( false === $date ) {
    		return $extra_options;
    	}
    
    	/**
    	 * URL parameter exists, so set navigateToEvents to 'current'.
    	 *
    	 * This means "Stay on Today (Show Current Calendar)" and prevents the calendar
    	 * from automatically jumping to past or future events when there are no events
    	 * in the current view.
    	 */
    	$extra_options['navigateToEvents'] = 'current';
    
    	return $extra_options;
    }

    Usage #

    Basic example

    Share this URL with your users:

    https://example.com/calendar-page/?calendar_date=2025-03-15 ย 

    The calendar will automatically display March 15, 2025 when loaded.

    Date format requirements

    The date must be in ISO 8601 format: YYYY-MM-DD ย 

    Valid examples:

    • ?calendar_date=2025-01-01 ย ย (January 1, 2025)
    • ?calendar_date=2025-12-31 ย ย (December 31, 2025)
    • ?calendar_date=2026-06-15 ย ย (June 15, 2026)

    Invalid examples:

    • ?calendar_date=03/15/2025 ย ย (US format – not supported)
    • ?calendar_date=15-03-2025 ย ย (European format – not supported)
    • ?calendar_date=2025-13-45 ย ย (Invalid date – no 13th month)

    Multiple calendars on one page

    The URL parameter will affect all calendars on the page. If you need different behavior for specific calendars, you can modify the snippet to check the $feed_id ย ย parameter:

    function gravitycalendar_add_initial_date_from_url( $calendar_options, $form_id, $feed_id ) {
        // Only apply to calendar feeds #5 and #12
        $allowed_feeds = array( 5, 12 );
    
        if ( ! in_array( $feed_id, $allowed_feeds, true ) ) {
            return $calendar_options;
        }
    
        // ... rest of the code continues here
    }

    Disabling automatic “Stay on Today” behavior

    By default, when a URL date parameter is present, the snippet automatically sets the Calendar feedโ€™s No Current Events Behavior to “Stay on Today (Show Current Calendar)”.

    If you want to keep your calendar’s configured No Current Events Behavior setting, remove this line from the snippet:

    add_filter( 'gravityview/calendar/extra_options', 'gravitycalendar_set_navigate_to_current_from_url', 10, 3 );

    And delete the gravitycalendar_set_navigate_to_current_from_url ย function at the bottom of the snippet.

    Customization #

    Changing the URL parameter name

    By default, the snippet uses calendar_date ย ย as the URL parameter. To use a different parameter name:

    1. Open the snippet file or your functions.php
    2. Find this line near the top:

    define( 'GRAVITYCALENDAR_DATE_URL_PARAM', 'calendar_date' ); ย 

    1. Change 'calendar_date' ย ย to your preferred parameter name:

    define( 'GRAVITYCALENDAR_DATE_URL_PARAM', 'start_date' ); ย 

    1. Save the file
    2. Your URLs will now use the new parameter:

    https://example.com/events/?start_date=2025-03-15 ย 

    Common customizations

    Use “date” as the parameter:

    define( 'GRAVITYCALENDAR_DATE_URL_PARAM', 'date' ); // URL: ?date=2025-03-15

    Use “event_date” as the parameter:

    define( 'GRAVITYCALENDAR_DATE_URL_PARAM', 'event_date' ); // URL: ?event_date=2025-03-15

    Troubleshooting #

    The calendar doesn’t navigate to the specified date

    Check these common issues:

    1. Date format: Make sure you’re using YYYY-MM-DD ย ย format
    2. Parameter name: Verify the URL parameter matches what’s defined in GRAVITYCALENDAR_DATE_URL_PARAM ย 
    3. Snippet activation: Confirm the snippet is active and saved correctly
    4. Browser cache: Clear your browser cache and try again

    How to view error logs

    If dates aren’t working, check your error logs:

    1. Enable logging in GravityKit
    2. Look for entries starting with “Invalid date format” or “Invalid date”
    3. The log will show exactly what date was received and why it failed validation

    Related resources #

    • FullCalendar initialDate option
    Still stuck? How can we help?

    How can we help?

    "*" indicates required fields

    This field is for validation purposes and should be left unchanged.
    Replies will go to this email.
    How can we help?*
    My pre-sale question is related to...*
    My WordPress skills are....*
    My Gravity Forms skills are...*
    You will be shown articles from our documentation.
    Vous pouvez nous รฉcrire dans votre langue maternelle si cโ€™est plus facile pour vousโ€”nous nous occuperons de la traduction!
    Puedes escribirnos en tu idioma nativo si te resulta mรกs fรกcil; ยกnosotros nos encargamos de la traducciรณn!
    Sie kรถnnen uns in Ihrer Muttersprache schreiben, wenn das fรผr Sie einfacher ist โ€“ wir kรผmmern uns um die รœbersetzung!
    U kunt ons in uw moedertaal schrijven als dat gemakkelijker voor u is โ€” wij zorgen voor de vertaling!
    Du kan skrive til oss pรฅ ditt morsmรฅl hvis det er enklere for deg โ€” vi tar oss av oversettelsen!
    Du kan skriva till oss pรฅ ditt modersmรฅl om det รคr lรคttare fรถr dig โ€” vi tar hand om รถversรคttningen!
    Vocรช pode nos escrever em seu idioma nativo se for mais fรกcil para vocรช โ€” nรณs cuidaremos da traduรงรฃo!
    Puoi scriverci nella tua lingua madre se ti รจ piรน facile โ€” penseremo noi alla traduzione!
    Please provide as much detail as you're able; this helps us provide you with faster support.
    Drop files here or
    Accepted file types: jpg, jpeg, gif, png, tiff, pdf, bmp, zip, json, csv, xls, xlsx, Max. file size: 256 MB.
      Stay informed?

      Was this page helpful?

      Table Of Contents
      • What you’ll learn
      • Before you begin
      • How it works
      • Installation
      • Usage
      • Customization
      • Troubleshooting
      • Related resources
      GravityKit
      • How to Build It
      • Pricing
      • Products
      • Our Team
      • Our Values
      • Work With Us
      • Coupons
      Support
      • Support
      • Contact
      • Documentation
      • Scope of Support
      • Brand Guidelines
      • Privacy Policy
      • Terms of Service (โ€œTermsโ€)
      About Us
      • GravityKit on Mastodon
      • GravityKit on Twitter
      • GravityKit Training Courses
      • GravityKit on Facebook
      • Join our Facebook Group
      • Facebook
      • Twitter
      Get notified of updates.

      Weโ€™re constantly improving GravityKit. Fill out your email below and weโ€™ll notify you anytime major updates drop.

      GravityKit is a Gravity Forms Certified Developer.

      Copyright ยฉ 2026, Katz Web Services, Inc.

      GravityKit and GravityView are registered trademarks of Katz Web Services, Inc.