Using Gravity Forms ‘gform_paypal_pre_ipn’ PHP filter

The gform_paypal_pre_ipn Gravity Forms PHP filter is used to cancel the IPN (Instant Payment Notification) processing.

Usage

add_filter('gform_paypal_pre_ipn', 'your_function_name', 10, 4);

Parameters

  • $cancel (boolean): False by default. Return as true to cancel IPN processing.
  • $_POST (array): The $_POST array posted by the PayPal IPN.
  • $entry (Entry Object): The entry from which the transaction the IPN is responding to was submitted.
  • $feed (Feed Object): The PayPal feed configuration data used to process the entry the IPN is responding to.

More information

See Gravity Forms Docs: gform_paypal_pre_ipn

Examples

Cancel IPN processing

This example shows how to return a true value and cancel the IPN processing.

add_filter('gform_paypal_pre_ipn', 'cancel_ipn');

function cancel_ipn($cancel) {
    return true;
}

Cancel IPN processing based on entry data

This example shows how to cancel IPN processing if the entry’s form ID is 5.

add_filter('gform_paypal_pre_ipn', 'cancel_ipn_for_form', 10, 4);

function cancel_ipn_for_form($cancel, $_POST, $entry, $feed) {
    if ($entry['form_id'] == 5) {
        return true;
    }
    return $cancel;
}

Cancel IPN processing based on custom criteria

This example shows how to cancel IPN processing if the total amount is less than 10.

add_filter('gform_paypal_pre_ipn', 'cancel_ipn_for_amount', 10, 4);

function cancel_ipn_for_amount($cancel, $_POST, $entry, $feed) {
    if ($_POST['mc_gross'] < 10) {
        return true;
    }
    return $cancel;
}

Log IPN data before processing

This example shows how to log the IPN data before processing it.

add_filter('gform_paypal_pre_ipn', 'log_ipn_data', 10, 4);

function log_ipn_data($cancel, $_POST, $entry, $feed) {
    error_log(print_r($_POST, true));
    return $cancel;
}

Modify IPN data before processing

This example shows how to modify the IPN data before processing it.

add_filter('gform_paypal_pre_ipn', 'modify_ipn_data', 10, 4);

function modify_ipn_data($cancel, $_POST, $entry, $feed) {
    $_POST['mc_gross'] = 100;
    return $cancel;
}