Using Gravity Forms ‘gform_payment_transaction_id’ PHP filter

The gform_payment_transaction_id filter allows you to modify the payment transaction ID displayed for the entry in the Payment Details section.

Usage

add_filter('gform_payment_transaction_id', 'your_function_name', 10, 3);

Parameters

  • $transaction_id (int): The payment transaction ID for the entry.
  • $form (Form Object): The form.
  • $entry (Entry Object): The entry.

More information

See Gravity Forms Docs: gform_payment_transaction_id

Examples

Change transaction ID to a fixed value

This example changes the transaction ID to 5 for all payment entries.

add_filter('gform_payment_transaction_id', 'change_transaction_id', 10, 3);

function change_transaction_id($transaction_id, $form, $entry) {
    $transaction_id = 5;
    return $transaction_id;
}

Add a prefix to transaction ID

This example adds a prefix “GF-” to the transaction ID.

add_filter('gform_payment_transaction_id', 'add_prefix_to_transaction_id', 10, 3);

function add_prefix_to_transaction_id($transaction_id, $form, $entry) {
    $transaction_id = 'GF-' . $transaction_id;
    return $transaction_id;
}

Multiply transaction ID by a factor

This example multiplies the transaction ID by 10.

add_filter('gform_payment_transaction_id', 'multiply_transaction_id', 10, 3);

function multiply_transaction_id($transaction_id, $form, $entry) {
    $transaction_id = $transaction_id * 10;
    return $transaction_id;
}

Modify transaction ID based on form ID

This example changes the transaction ID only for a specific form with ID 2.

add_filter('gform_payment_transaction_id', 'modify_transaction_id_based_on_form', 10, 3);

function modify_transaction_id_based_on_form($transaction_id, $form, $entry) {
    if ($form['id'] == 2) {
        $transaction_id = 'FORM2-' . $transaction_id;
    }
    return $transaction_id;
}

Modify transaction ID based on entry data

This example changes the transaction ID based on the entry data.

add_filter('gform_payment_transaction_id', 'modify_transaction_id_based_on_entry', 10, 3);

function modify_transaction_id_based_on_entry($transaction_id, $form, $entry) {
    if ($entry['payment_status'] == 'Paid') {
        $transaction_id = 'PAID-' . $transaction_id;
    }
    return $transaction_id;
}