- 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
Validate Field Filter Hook
Overview
The suredonation_validate_field filter allows developers to add custom validation rules for individual SureDonation form fields.
The filter runs after SureDonation’s core validation for each field. You can use it to validate custom field types or apply additional validation rules that are not included in the default validation.
If your callback returns a non-empty string, the field is considered invalid, and the returned string is displayed as the field’s validation error message.
When This Filter Runs
The filter is applied during form data validation, after SureDonation performs its built-in validation for the field.
It is useful when you need to:
- Add custom validation rules.
- Validate custom field blocks.
- Apply business-specific validation requirements.
- Add validation based on the submitted field value.
- Provide custom validation error messages.
Filter Signature
apply_filters( 'suredonation_validate_field', $error, $value, $config, $form_id, $block_name );Parameters
| Parameter | Type | Description |
| $error | string | The current validation error from core validation. An empty string (”) means the value has passed core validation. |
| $value | string | The submitted and trimmed field value. |
| $config | array | The stored block configuration for the field. It can contain values such as block_name, slug, required, and other validation rules. |
| $form_id | int | The donation form post ID. |
| $block_name | string | The block name, such as suredonation/input. |
Return Value
Your callback should return a string.
| Return Value | Result |
| Non-empty string | The field is marked as invalid. The returned string is used as the validation error message. |
| Empty string (”) | The field passes validation. |
When core validation has already returned an error, it is recommended to return the existing $error instead of replacing it unless you intentionally want to override the message.
Basic Usage
Use add_filter() to register your custom validation callback.
add_filter( 'suredonation_validate_field', 'your_custom_function', 10, 5 );
function your_custom_function( $error, $value, $config, $form_id, $block_name ) {
    // Return a non-empty string to fail validation.
    return $error;
}Example: Validate a Custom Field
The following example validates a custom field block and requires the submitted value to start with MY-.
add_filter( 'suredonation_validate_field', 'mysite_validate_field', 10, 5 );
function mysite_validate_field( $error, $value, $config, $form_id, $block_name ) {
    // Only validate our custom block
    // and do not override an existing error.
    if ( '' === $error && 'mysite/custom-field' === $block_name ) {
        if ( ! str_starts_with( $value, 'MY-' ) ) {
            return __( 'This code must start with "MY-".', 'my-plugin' );
        }
    }
    return $error;
}How the Example Works
- The callback checks whether core validation has already returned an error.
- It checks whether the field belongs to mysite/custom-field.
- It verifies that the submitted value starts with MY-.
- If the value does not meet the requirement, a custom error message is returned.
- If the value is valid, the existing $error is returned.
Recommended Usage
When adding custom validation, check the existing $error before applying your own validation.
if ( '' === $error ) {
    // Apply custom validation.
}This prevents your custom validation from unnecessarily replacing an error generated by SureDonation’s core validation.
Related Hooks
- suredonation_validatable_blocks: Controls which blocks are included in field validation.
- suredonation_field_block_config: Filters the stored configuration for a donation form field.
- suredonation_default_validation_messages: Filters the default validation messages used by SureDonation.
We don't respond to the article feedback, we use it to improve our support content.