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

suredonation_import_campaigns_limit Filter Hook

Overview

The suredonation_import_campaigns_limit filter controls the maximum number of campaigns that SureDonation imports in a single request when restoring a campaigns JSON file.

You can use this filter to lower or increase the import limit based on your server’s available resources and PHP execution limits.

The campaign import process runs synchronously and does not provide a rollback. Setting an appropriate limit can help reduce the risk of a timeout during large imports.

When to Use This Filter

Use this filter when you need to:

  • Lower the number of campaigns imported per request.
  • Adjust the import limit for shared or resource-constrained hosting.
  • Reduce the risk of PHP execution timeouts.
  • Control the size of individual campaign import operations.

Filter Signature

apply_filters( 'suredonation_import_campaigns_limit', 1000);

Parameters

ParameterTypeDescription
$limitintMaximum number of campaigns that can be imported in a single request.

Default Value

The default limit is: 1000

Campaigns beyond this limit are removed from the import payload before the import begins.

Return Value

Return the campaign import limit as an integer.

return $limit;

For example: return 200;

This limits each import request to 200 campaigns.

Basic Usage

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

function your_custom_function( $limit ) {

    // Modify the campaign import limit.

    return $limit;

}

Example: Lower the Import Limit

If your website is hosted on a resource-constrained server with a short PHP execution time, you can lower the limit.

add_filter( 'suredonation_import_campaigns_limit',   'mysite_lower_campaign_import_cap',  10,   1);

function mysite_lower_campaign_import_cap( $limit ) {

    // Shared hosting with a 30-second execution limit.

    return 200;

}

With this configuration, a maximum of 200 campaigns will be processed in each import request.

Example: Set a Higher Import Limit

If your server has sufficient resources and you need to process more campaigns per request, you can increase the limit.

add_filter( 'suredonation_import_campaigns_limit', function ( $limit ) {

        return 1500;

    }

);

How the Campaign Import Works

The filter is applied during the campaigns JSON import process:

  1. SureDonation receives the campaigns JSON file.
  2. The campaign import limit is determined.
  3. The suredonation_import_campaigns_limit filter is applied.
  4. Campaigns beyond the returned limit are removed from the payload.
  5. The remaining campaigns are imported.
  6. Campaigns and their linked forms are created as published.
  7. Form IDs are remapped from the original site to the newly created form IDs.
  8. Campaign block content and default-form references are updated.
  9. Relevant SureDonation metadata is restored.

Important: No Rollback

The campaign import process does not provide a rollback mechanism.

If an import is interrupted by a timeout or another server error, campaigns that were already created remain on the site.

For this reason, lowering the import limit is recommended on constrained hosting environments.

Importing More Than the Limit

Campaigns beyond the configured limit are not queued for another request.

They are removed from the current import payload.

For example, if the limit is: return 200;

and the JSON file contains 500 campaigns, only the first 200 campaigns are processed.

If you need to import all 500 campaigns, split the JSON file into smaller files and import them separately.

Campaign and Form Data

During the import:

  • Campaigns are created as published.
  • Linked forms are also created as published.
  • The embedded formId values are rewritten from the old IDs to the newly created IDs.
  • Form IDs are updated in both form content and campaign block content.
  • The campaign’s default-form reference is remapped.
  • Only _suredonation_* metadata is restored.

Recommended Configuration

For resource-constrained hosting, start with a lower limit:

add_filter( 'suredonation_import_campaigns_limit',  function () {

        return 200;

    }

);

Test the import and increase the value gradually if the server can handle the workload reliably.

Related Hooks

  • Suredonation_export_campaigns_limit: Controls the maximum number of campaigns included during campaign export.
  • Suredonation_import_phase_mappers: Filters the mapper classes used for CSV import phases.
  • Suredonation_export_secret_option_keys: Controls option keys that should be excluded from 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