|
/ Documentation /Developer Hooks & Events/ suredonation_export_campaigns_limit Filter Hook

suredonation_export_campaigns_limit Filter Hook

Overview

The suredonation_export_campaigns_limit filter controls the maximum number of campaigns included in a single campaign export from SureDonation → Tools → Import & Export.

This filter is useful for controlling memory usage and execution time when exporting a large number of campaigns.

Each campaign may also load its linked donation forms and metadata, so exporting a large number of campaigns can require significant server resources.

When to Use This Filter

Use this filter when you need to:

  • Reduce memory usage during campaign exports.
  • Prevent PHP execution timeouts.
  • Export campaigns in smaller batches.
  • Adjust the export limit based on your hosting environment.
  • Handle large campaign libraries more safely.

Filter Signature

apply_filters( 'suredonation_export_campaigns_limit', 10000);

Parameters

ParameterTypeDescription
$limitintMaximum number of campaigns included in a single export.

Default Value

10000

Return Value

Return the maximum number of campaigns that should be included in the export.

return 500;

The returned value is used as the campaign export limit.

Basic Usage

add_filter('suredonation_export_campaigns_limit', 'your_custom_function', 10, 1 );

function your_custom_function( $limit ) {

// Modify the campaign export limit.

return $limit;

}

Example: Lower the Export Limit

If the website is hosted on shared hosting with limited memory, you can reduce the number of campaigns exported in one request.

add_filter( 'suredonation_export_campaigns_limit', 'mysite_lower_campaign_export_cap', 10, 1);

function mysite_lower_campaign_export_cap( $limit ) {

// Export fewer campaigns per request.

return 500;

}

This limits the export to 500 campaigns per request.

Why Adjust the Export Limit?

Campaign exports can require more resources than expected because SureDonation also processes data associated with each campaign, including:

  • Linked donation forms
  • Form metadata
  • Campaign metadata
  • Form references within campaign content

Therefore, exporting 1,000 campaigns does not simply mean processing 1,000 database records.

Recommended Configuration

For a website with limited server resources, start with a smaller limit:

add_filter( 'suredonation_export_campaigns_limit', function () {

return 500;

}

);

If the export completes successfully, you can gradually increase the limit based on your hosting capacity.

Troubleshooting Export Timeouts

If the campaign export fails, times out, or produces an incomplete JSON file:

  1. Reduce the campaign export limit.
  2. Run the export again.
  3. Increase the limit gradually if the server can handle it.
  4. Avoid increasing the limit on servers with strict memory or execution-time limits.

For example: return 250;

may be more appropriate for a resource-constrained server than: return 10000;

Important: Synchronous Export

The campaign export runs synchronously during the request that starts the download.

This means the server must complete the export before the request finishes.

A very high limit can increase the risk of:

  • PHP memory exhaustion
  • Request timeouts
  • Incomplete exports
  • Truncated JSON files

If the export is timing out, lower the limit rather than simply increasing the server limits.

Related Hooks

  • suredonation_import_campaigns_limit: Controls the maximum number of campaigns imported in a single request.
  • suredonation_export_secret_option_keys: Prevents sensitive settings from being included in exports.
  • suredonation_export_one_time_only: Controls whether recurring donations are included in donation exports.
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents
Scroll to Top