One-click hooks
Deze inhoud is nog niet vertaald.
One-click links submit a prefilled form as soon as someone opens the link. These hooks tune how the plugin tells a real visit from an automated request, and how long a failed submission can still be restored.
cs_forms_one_click_non_visit_reason
Section titled “cs_forms_one_click_non_visit_reason”Filter · includes/class-oneclick.php
Filters why a one-click request is not treated as a visit by a person. Requests that are clearly automated, such as HEAD requests, browser prefetches, crawlers, link previews or non-HTML fetches, get the prefilled form without a submission. Return an empty string to submit the form anyway, or any non-empty reason to show the form without submitting.
| Parameter | Type | Description |
|---|---|---|
$reason |
string |
head, prefetch, bot or not_html, or '' when the request is treated as a visit. |
Returns: string — '' to submit the form, or a non-empty reason to only show the prefilled form.
add_filter('cs_forms_one_click_non_visit_reason', function ($reason) { // Treat requests from our own link checker as non-visits. if (strpos((string) ($_SERVER['HTTP_USER_AGENT'] ?? ''), 'MyLinkChecker') !== false) { return 'bot'; } return $reason;});cs_forms_one_click_draft_expiration_days
Section titled “cs_forms_one_click_draft_expiration_days”Filter · includes/class-oneclick.php
Filters how many days a failed one-click draft, and with it its restore link, is kept. It runs when Gravity Forms purges expired incomplete submissions. Normal Save and Continue drafts keep the Gravity Forms lifetime, which you set with gform_incomplete_submissions_expiration_days.
| Parameter | Type | Description |
|---|---|---|
$days |
int|float |
Number of days. Default 1. A negative value is treated as 0. |
Returns: int|float — the number of days.
add_filter('cs_forms_one_click_draft_expiration_days', function ($days) { return 7;});cs_settings_page_capability
Section titled “cs_settings_page_capability”Filter · includes/class-oneclicklinks.php
This CampaignSuite Core hook is reused by the One-click links admin page. It decides which capability is needed to manage one-click links, the same one as for the CampaignSuite settings pages. The default is manage_options. See the CampaignSuite Core hooks for its full description.
| Parameter | Type | Description |
|---|---|---|
$capability |
string |
The capability. Default 'manage_options'. |
Returns: string — the capability.
add_filter('cs_settings_page_capability', function ($capability) { return 'edit_others_posts';});