PDF for GravityView Hooks – gfpdf_gv_share_pdf_limit_window
Description
Use this filter to change how long each Share PDF limit is measured over. The default window is one day for share_recipient_daily and one hour for the rest.
When a window ends, the count resets to zero and unused emails don't carry over. Each counter's window starts at a slightly different time, so counters don't all reset at once.
A longer window with the same limit allows fewer emails over time, and a refused sender waits longer to try again. A shorter window does the opposite. When you change a window, you'll usually want to scale the limit to match with gfpdf_gv_share_pdf_limit.
See Spam Protection and Sending Limits. Related hooks: gfpdf_gv_share_pdf_limit_exempt_caps and gfpdf_gv_share_pdf_limit_logged_in_multiplier.
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$window | int
- The length of the window, in seconds.
- Values below
1are treated as1. - The default value is
86400(one day) forshare_recipient_daily, and3600(one hour) for the rest.
$context | string
- Which limit the window is for. The
share_addressandshare_networkcounters use theshare_clientwindow. - Valid values include:
share_clientshare_recipientshare_recipient_dailyshare_site
$logged_in | bool
- Whether the sender is logged in.
Usage
Measure the per-sender limit over a whole day, and allow 20 emails a day:
add_filter( 'gfpdf_gv_share_pdf_limit_window', function( $window, $context, $logged_in ) {
return $context === 'share_client' ? DAY_IN_SECONDS : $window;
}, 10, 3 );
add_filter( 'gfpdf_gv_share_pdf_limit', function( $max, $context, $logged_in ) {
return $context === 'share_client' ? 20 : $max;
}, 10, 3 );
Source Code
This filter is located in src/Pdf/Access/RenderBudget.php of the PDF for GravityView extension.