gpns_unsubscribe_url_args
Description
Filter the arguments used to build the unsubscribe URL.
Usage
Filter unsubscribe URL arguments for all unsubscribe URLs.
add_filter( 'gpns_unsubscribe_url_args', 'my_custom_function' );
Filter unsubscribe URL arguments for all unsubscribe URLs for a given form.
add_filter( 'gpns_unsubscribe_url_args_FORMID', 'my_custom_function' );
Filter unsubscribe URL arguments for a specific notification.
add_filter( 'gpns_unsubscribe_url_args_FORMID_NID', 'my_custom_function' );
Parameters
unsubscribe_info array
Settings used to construct the unsubscribe URL that will be sent in the Notification.
email string
The email address to unsubscribe.
fid int
The form ID that the current Notification belongs to.
nid string
The current Notification’s ID.
scope string
The scope of the unsubscribe action. Defaults to unsubscribing from all scheduled notifications. To unsubscribe the email from the current form’s scheduled notifications, change the scope to
form_id
. To unsubscribe from only the current notification, change scope tonid
.url string|null
The URL to redirect to after unsubscribing. If left
null
, a generic unsubscribe page will be used.
entry array
The current entry.
notification array
The current notification.
email string
The email address being unsubscribed.
Examples
Change scope and unsubscribe success URL
The following example will change the behavior of a specific notification’s unsubscribe URL to only be scoped to the current notification rather than all notification. It will also change the unsubscribe success URL for the specific notification.
As an example, if the URL is…
https://your-site.domain/wp-admin/admin.php?page=gf_edit_forms&view=settings&subview=notification&id=6&nid=62a750fe982af
…the Form ID is 6
and the Notification ID is 62a750fe982af
.
In the snippet, replace 123
with your Form ID and 1a23bc456def7
with your Notification ID.
<?php
/**
* Gravity Perks // Notification Scheduler // Change Scope and Unsubscribe Success URL
* https://gravitywiz.com/documentation/gravity-forms-notification-scheduler/
*/
// Update "123" to the form ID and "1a23bc456def7" to the notification ID.
add_filter( 'gpns_unsubscribe_url_args_123_1a23bc456def7', function ( $unsubscribe_info ) {
// Only unsubscribe from current notification
$unsubscribe_info['scope'] = 'nid';
// Change unsubscribe success URL.
$unsubscribe_info['url'] = home_url( '/example-unsubscribe-page' );
return $unsubscribe_info;
} );
Since
This filter is available since Gravity Forms Notification Scheduler 1.1.