Using Gravity Forms ‘gform_paypalpaymentspro_log_api_request’ PHP filter

The gform_paypalpaymentspro_log_api_request filter in Gravity Forms controls whether the API request sent to PayPal is logged or not.

Usage

add_filter('gform_paypalpaymentspro_log_api_request', 'your_function_name', 10, 1);

Parameters

  • $log_request (bool): Set to true to log the request, and false to not. Default is false.

More information

See Gravity Forms Docs: gform_paypalpaymentspro_log_api_request

Examples

Log API requests

Enable logging of PayPal API requests by returning true:

add_filter('gform_paypalpaymentspro_log_api_request', 'log_request', 10, 1);
function log_request($log_request) {
    return true;
}

Disable logging for specific form

Disable logging of API requests for a specific form with form ID 5:

add_filter('gform_paypalpaymentspro_log_api_request', 'disable_logging_for_form', 10, 2);
function disable_logging_for_form($log_request, $form_id) {
    if ($form_id == 5) {
        return false;
    }
    return $log_request;
}

Log API requests only for specific user roles

Enable logging of API requests only for users with the ‘administrator’ role:

add_filter('gform_paypalpaymentspro_log_api_request', 'log_request_for_admins', 10, 1);
function log_request_for_admins($log_request) {
    $user = wp_get_current_user();
    if (in_array('administrator', $user->roles)) {
        return true;
    }
    return $log_request;
}

Log API requests based on amount

Enable logging of API requests for transactions with an amount greater than or equal to $50:

add_filter('gform_paypalpaymentspro_log_api_request', 'log_request_based_on_amount', 10, 2);
function log_request_based_on_amount($log_request, $transaction_amount) {
    if ($transaction_amount >= 50) {
        return true;
    }
    return $log_request;
}

Log API requests during specific hours

Enable logging of API requests only during specific hours (e.g., between 8 AM and 5 PM):

add_filter('gform_paypalpaymentspro_log_api_request', 'log_request_during_specific_hours', 10, 1);
function log_request_during_specific_hours($log_request) {
    $current_hour = date('G');
    if ($current_hour >= 8 && $current_hour <= 17) {
        return true;
    }
    return $log_request;
}