- Handle Custom Stripe Webhook Events
- suredonation_export_secret_option_keys Filter Hook
- suredonation_import_batch_complete Action Hook
- suredonation_import_complete Action Hook
- suredonation_import_donation_inserted Action Hook
- suredonation_import_donor_inserted Action Hook
- suredonation_import_session_created Action Hook
- suredonation_import_givewp_batch_complete Action Hook
- suredonation_import_givewp_session_created Action Hook
- suredonation_privacy_data_exported Action Hook
- Validate Field Filter Hook
- Validatable Blocks Filter Hook
- Update donation data, Filter Hook
- OttoKit Integration: suredonation_suretriggers_integration_data_filter Filter Hook
- suredonation_show_setup_gateway_notice Filter Hook
- suredonation_show_review_notice_gateway Filter Hook
- suredonation_show_review_notice_donation Filter Hook
- suredonation_registered_payment_methods Filter Hook
- suredonation_register_additional_blocks Filter Hook
- suredonation_receipt_html Filter Hook
- suredonation_phone_geo_enabled Filter Hook
- suredonation_phone_geo_api_hourly_cap Filter Hook
- suredonation_paypal_webhook_handle_event Filter Hook
- suredonation_paypal_sdk_args Filter Hook
- suredonation_output_campaign_meta_tags Filter Hook
- suredonation_new_donor_user_data Filter Hook
- suredonation_integration_payload Filter Hook
- suredonation_import_phase_mappers Filter Hook
- suredonation_import_givewp_phases Filter Hook
- suredonation_import_givewp_phase_mappers Filter Hook
- suredonation_import_donation_row Filter Hook
- suredonation_import_campaigns_limit Filter Hook
- suredonation_field_block_config Filter Hook
- suredonation_export_one_time_only Filter Hook
- suredonation_export_campaigns_limit Filter Hook
- suredonation_email_smart_tags Filter Hook
- suredonation_email_smart_tag_groups Filter Hook
- suredonation_email_field_char_limits Filter Hook
- suredonation_disable_default_styles Filter Hook
- suredonation_default_validation_messages Filter Hook
- suredonation_default_email_notifications Filter Hook
- suredonation_create_donation_data Filter Hook
- suredonation_config_abilities Filter Hook
- suredonation_available_payment_methods Filter Hook
- suredonation_allowed_form_html Filter Hook
- suredonation_allowed_form_blocks Filter Hook
- Validatable Blocks Filter Hook
- Update donation data, Filter Hook
- OttoKit Integration: suredonation_suretriggers_integration_data_filter Filter Hook
- suredonation_show_setup_gateway_notice Filter Hook
- suredonation_show_review_notice_gateway Filter Hook
- suredonation_show_review_notice_donation Filter Hook
- suredonation_registered_payment_methods Filter Hook
- suredonation_register_additional_blocks Filter Hook
- suredonation_receipt_html Filter Hook
- suredonation_phone_geo_enabled Filter Hook
- suredonation_phone_geo_api_hourly_cap Filter Hook
- suredonation_paypal_webhook_handle_event Filter Hook
- suredonation_paypal_sdk_args Filter Hook
- suredonation_output_campaign_meta_tags Filter Hook
- suredonation_new_donor_user_data Filter Hook
- suredonation_integration_payload Filter Hook
- suredonation_import_phase_mappers Filter Hook
- suredonation_import_givewp_phases Filter Hook
- suredonation_import_givewp_phase_mappers Filter Hook
- suredonation_import_donation_row Filter Hook
- suredonation_import_campaigns_limit Filter Hook
- suredonation_field_block_config Filter Hook
- suredonation_export_secret_option_keys Filter Hook
- suredonation_export_one_time_only Filter Hook
- suredonation_export_campaigns_limit Filter Hook
- suredonation_email_smart_tags Filter Hook
- suredonation_email_smart_tag_groups Filter Hook
- suredonation_email_field_char_limits Filter Hook
- suredonation_disable_default_styles Filter Hook
- suredonation_default_validation_messages Filter Hook
- suredonation_default_email_notifications Filter Hook
- suredonation_create_donation_data Filter Hook
- suredonation_config_abilities Filter Hook
- suredonation_available_payment_methods Filter Hook
- suredonation_allowed_form_html Filter Hook
- suredonation_allowed_form_blocks Filter Hook
- suredonation_import_batch_complete Action Hook
- suredonation_import_complete Action Hook
- suredonation_import_donation_inserted Action Hook
- suredonation_import_donor_inserted Action Hook
- suredonation_import_session_created Action Hook
- suredonation_import_givewp_batch_complete Action Hook
- suredonation_import_givewp_session_created Action Hook
- suredonation_privacy_data_exported Action Hook
- suredonation_enqueue_form_frontend_scripts Action Hook
- suredonation_after_form_duplicated Action Hook
- suredonation_email_sent Action Hook
- suredonation_donor_user_created Action Hook
- suredonation_donation_refunded Action Hook
- suredonation_donation_status_changed Action Hook
- suredonation_donation_completed Action Hook
- suredonation_new_donation Action Hook
- suredonation_donation_created Action Hook
Update donation data, Filter Hook
Overview
The suredonation_update_donation_data filter allows developers to modify the donation data before it is saved during a SureDonation REST API update request.
You can use this filter to add, remove, or modify values before the updated donation data is persisted.
The array returned by the filter is the data that SureDonation uses for the update.
When to Use This Filter
Use this filter when you need to customize donation data during a REST API update.
For example, you can use it to:
- Add custom donation fields.
- Modify existing donation values.
- Set a default value.
- Apply custom business rules.
- Add additional data before the donation is updated.
Filter Signature
apply_filters(Â 'suredonation_update_donation_data', $update_data, $request, $donation_id );Parameters
| Parameter | Type | Description |
| $update_data | array | Donation data prepared for the update. It contains non-null values from the allowed request parameters. |
| $request | WP_REST_Request | The REST API request containing the update data. |
| $donation_id | int | The ID of the donation being updated. |
Available Update Fields
The $update_data array can contain the following fields:
- campaign_id
- donor_name
- donor_email
- donor_phone
- amount
- fees_covered
- donation_type
- is_anonymous
- donor_comment
- payment_status
- gateway
- transaction_id
The $update_data array may be empty if no supported fields were supplied in the REST request.
Return Value
The callback must return an array containing the donation data to be updated.
The returned array can be:
- The original $update_data array.
- A modified version of $update_data.
- An empty array if no update should be performed.
SureDonation only writes the update when the returned array is not empty.
Basic Usage
Use add_filter() to register your callback.
add_filter( 'suredonation_update_donation_data', 'your_custom_function', 10, 3 );
function your_custom_function( $update_data, $request, $donation_id ) {
    // Modify the update data here.
    return $update_data;
}Example: Add a Currency Value
The following example adds a currency value to the update data whenever there is data available to update.
add_filter( 'suredonation_update_donation_data', 'mysite_force_currency', 10, 3 );
function mysite_force_currency( $update_data, $request, $donation_id ) {
    if ( ! empty( $update_data ) ) {
        $update_data['currency'] = 'USD';
    }
    return $update_data;
}In this example, the currency value is added to the data before it is persisted.
Example: Modify an Existing Value
You can also modify an existing value before the donation is updated.
add_filter( 'suredonation_update_donation_data', 'mysite_modify_donor_name', 10, 3 );
function mysite_modify_donor_name( $update_data, $request, $donation_id ) {
    if ( isset( $update_data['donor_name'] ) ) {
        $update_data['donor_name'] = sanitize_text_field(
            $update_data['donor_name']
        );
    }
    return $update_data;
}Update Flow
The filter is applied as part of the REST API donation update process:
- A REST API update request is received.
- SureDonation validates the request.
- SureDonation confirms that the donation exists.
- Supported request parameters are collected into $update_data.
- The suredonation_update_donation_data filter is applied.
- Your callback can modify the update data.
- SureDonation persists the returned data.
- If the returned array is empty, no update is performed.
Related Hooks
- suredonation_create_donation_data
Filters donation data before a new donation is created. - suredonation_donation_status_changed
Runs when the status of a donation changes.
We don't respond to the article feedback, we use it to improve our support content.