How to Customize Available Date Ranges for the WPForms Dashboard Widget

Introduction

Would you like to customize date ranges for the WPForms Dashboard Widget? Using a small PHP snippet you can easily add as many different date ranges as you’d like. In this tutorial, we’re going to walk you through how to customize these date ranges so that you can get exactly what you need for your easy view reporting.

By default, the widget will allow you to choose a 7 or 30 date range for your form entry counts.

The WPForms dashboard widget by default will only show you the last 7 and 30 day time spans

To learn more about the WPForms Dashboard Widget, check out this documentation.

Adding the snippet

For the purpose of this tutorial, we want to add an additional date range of the last 90 days. In order to do this, you’ll need to add this snippet to your site.

If you need any assistance in how to add snippets to your site, please review this tutorial.

/**
 * Customize the dashboard date range to show the last 90 days entry count
 *
 * @link https://wpforms.com/developers/how-to-add-an-additional-time-span-to-the-dashboard-widget/
 */

function wpf_dev_dash_widget_timespan_options( $options ) {

    $options[] = 90;

    return $options;

}

add_filter( 'wpforms_dash_widget_timespan_options', 'wpf_dev_dash_widget_timespan_options', 10, 1 );

Viewing the changes

Click Dashboard from the WordPress admin menu on the left and now you’ll see you have a new option in the dropdown of 90 days in the Total Entries by Form dropdown.

Now you can easily customize date ranges with this small snippet

And that is all you need to customize the date ranges available inside the WPForms Dashboard Widget! You’ve now successfully increased your dashboard widget time span to include a new 90 days range. If you’re not already familiar with the Entries screen, we recommend you take a look at this article for a complete guide to WPForms entries..

Filter Reference: wpforms_dash_widget_timespan_options

FAQ

Q: Can I add more ranges?

A: Absolutely! Here’s an example of including a 60 day range as well as the 90 day range.

/**
 * Adding 60 and 90 day range to the dashboard widget time span.
 *
 * @link https://wpforms.com/developers/how-to-add-an-additional-time-span-to-the-dashboard-widget/
 */

function wpf_dev_dash_widget_timespan_options( $options ) {

    $options[] = 60;
    $options[] = 90;

    return $options;

}

add_filter( 'wpforms_dash_widget_timespan_options', 'wpf_dev_dash_widget_timespan_options', 30, 1 );

Q: Will this also change the Entries screen?

A: No, this filter will only change the dashboard widget on the main WordPress Dashboard screen.