PDF for GravityView Hooks – gfpdf_gv_share_pdf_limit
Description
Use this filter to change or turn off the limits on how many emails the Share Single Entry PDF field can send. Each email is counted against several limits and is refused by the first one it would exceed. See Spam Protection and Sending Limits for who is counted and who is exempt.
| Context | Counts | Default | Window |
|---|---|---|---|
share_client | Each sender: the IP address for logged-out visitors, or the account for logged-in users | 5 | 1 hour |
share_recipient | Each recipient email address | 3 | 1 hour |
share_recipient_daily | Each recipient email address | 10 | 1 day |
share_site | The whole site | 100 | 1 hour |
The share_client limit is also applied to two wider counters, which aren't passed to this filter:
share_address: each IP address, for logged-in users only. Same limit asshare_client.share_network: each IPv6 /48 network. Six times theshare_clientlimit (30 by default).
They follow whatever you return for share_client.
For logged-in users, the share_client and share_recipient limits are multiplied by gfpdf_gv_share_pdf_limit_logged_in_multiplier (2 by default). The share_recipient_daily and share_site limits are the same for everyone.
A sender over a share_client, share_address, share_network or share_site limit is told when to try again. A send to a recipient over a share_recipient or share_recipient_daily limit is skipped, but the sender sees the usual confirmation message. Every refusal is written to the PDF for GravityView log.
Each email also counts toward the Single Entry PDF render budget. Change the window length with gfpdf_gv_share_pdf_limit_window.
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$max | int
- The number of emails allowed per window.
- A value below
1turns that limit off. Forshare_client, this also turns offshare_addressandshare_network. - For logged-in users, the
share_clientandshare_recipientlimits are multiplied by gfpdf_gv_share_pdf_limit_logged_in_multiplier after this filter runs. - The default value depends on
$context(see the table above).
$context | string
- Which limit is being set.
- Valid values include:
share_clientshare_recipientshare_recipient_dailyshare_site
$logged_in | bool
- Whether the sender is logged in.
Usage
Let each logged-out visitor send 10 emails an hour (20 for logged-in users):
add_filter( 'gfpdf_gv_share_pdf_limit', function( $max, $context, $logged_in ) {
return $context === 'share_client' ? 10 : $max;
}, 10, 3 );
Raise the site-wide limit to 500 emails an hour:
add_filter( 'gfpdf_gv_share_pdf_limit', function( $max, $context, $logged_in ) {
return $context === 'share_site' ? 500 : $max;
}, 10, 3 );
Turn off the site-wide limit:
add_filter( 'gfpdf_gv_share_pdf_limit', function( $max, $context, $logged_in ) {
return $context === 'share_site' ? 0 : $max;
}, 10, 3 );
To lift the limits for your staff only, give their role a capability listed in gfpdf_gv_share_pdf_limit_exempt_caps.
Source Code
This filter is located in src/Pdf/Access/RenderBudget.php of the PDF for GravityView extension. The default limits are in src/Pdf/Access/ShareLimit.php.