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

suredonation_config_abilities Filter Hook

Overview

The suredonation_config_abilities filter allows developers to customize the set of SureDonation abilities registered with the WordPress Abilities API.

The WordPress Abilities API provides a standardized way to expose plugin capabilities to WordPress and compatible tools, including MCP-based integrations.

This filter runs after SureDonation has assembled its built-in abilities for areas such as:

  • Campaigns
  • Donations
  • Donors
  • Forms
  • Analytics

Use this filter to add new abilities or modify existing ability definitions.

When to Use This Filter

Use this filter when you need to:

  • Register a custom ability from an extension.
  • Modify an existing SureDonation ability.
  • Extend SureDonation functionality for an MCP-compatible integration.
  • Expose custom reports or operations through the WordPress Abilities API.

Filter Signature

apply_filters( 'suredonation_config_abilities', $abilities);

Parameters

ParameterTypeDescription
$abilitiesarrayThe merged list of SureDonation ability definitions.

The array contains the built-in SureDonation ability definitions after they have been assembled.

Return Value

Return an array containing the ability definitions.

return $abilities;

If the callback returns a non-array value, SureDonation converts the result to an empty array.

Basic Usage

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

function your_custom_function( $abilities ) {

// Add or modify ability definitions here.

return $abilities;

}

Example: Register a Custom Ability

The following example adds a custom report ability.

add_filter( 'suredonation_config_abilities', 'mysite_add_ability', 10, 1);

function mysite_add_ability( $abilities ) {

$abilities[] = [

'name'  => 'my-plugin/custom-report',

'label' => 'Custom Report',

// Add the remaining ability definition here.

];

return $abilities;

}

The exact properties required by the WordPress Abilities API depend on the capability being registered.

Example: Modify an Existing Ability

You can also inspect the existing ability definitions and modify a specific ability.

add_filter( 'suredonation_config_abilities', 'mysite_modify_ability', 10, 1);

function mysite_modify_ability( $abilities ) {

foreach ( $abilities as &$ability ) {

if ( 'suredonation/custom-ability' === $ability['name'] ) {

$ability['label'] = 'My Custom Label';

}

}

return $abilities;

}

When modifying existing definitions, make sure the ability name matches the registered ability exactly.

Ability Registration Flow

The filter runs after SureDonation has assembled its built-in ability definitions.

SureDonation built-in abilities

          â†“

Campaign abilities
Donation abilities
Donor abilities
Form abilities
Analytics abilities

          â†“

suredonation_config_abilities

          â†“

Custom abilities added or definitions modified

          â†“

Abilities registered with WordPress

Important: Result Is Memoized

The ability configuration is memoized after the first call.

This means the result of Config_Ability::get_abilities() is cached for subsequent calls during the same request lifecycle.

Because of this:

  • Add your filter before SureDonation retrieves the ability configuration.
  • Avoid relying on changing the filtered result later in the same request.
  • Keep the callback deterministic.

This filter is applied in:

Config_Ability::get_abilities()

When registering a custom ability:

  • Use a unique ability name, preferably prefixed with your plugin or organization name.
  • Return the complete $abilities array.
  • Follow the WordPress Abilities API structure for your ability definition.
  • Avoid removing built-in abilities unless there is a specific compatibility requirement.
  • Keep the callback lightweight because the result is memoized after the first call.

Related Hooks

None.

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