1. Home
  2. Documentation
  3. WordPress SDK
  4. Filters & Actions Hooks

Filters & Actions Hooks

The Freemius WordPress SDK provides a collection of filters and actions that allow developers to customize and extend the functionality of their WordPress plugins or themes.

The concept is very similar to WordPress’ own filters and actions, also known as hooks. The only difference is that we need to use the Freemius SDK instance to call the relevant methods.

Filters Hooks

Filters allow developers to modify specific data or behavior within the Freemius SDK. To add a filter, use the following method from the Freemius instance:

my_fs()->add_filter(
  string $tag, 
  callable $callback,
  $priority = 10,
  $accepted_args = 1
);

The method signature is the same as WordPress’ add_filter function. The following filters are available:

connect_url

Modifies the URL used for the activation screen.

trial_promotion_message

Customizes the message in the admin notice promoting trial usage to users.

is_long_term_user

Determines if a user is considered long-term based on custom criteria. The uninstall reasons shown in the deactivation feedback dialog are determined based on this user type.

uninstall_reasons

Defines the reasons presented to users in the deactivation feedback dialog during product deactivation.

is_plugin_update

Checks if Freemius was first added in a product update.

api_domains

Specifies API domains to include in an activation error message about domains that need to be whitelisted.

support_forum_submenu

Manages the visibility of the support forum submenu.

support_forum_url

Sets the URL for the support forum link for the product.

connect_message

Customizes the message displayed during the activation process.

connect_message_on_update

Adjusts the connection message shown during the activation process when Freemius was first added in a product update.

uninstall_confirmation_message

Customizes the confirmation message to show in an additional panel within the deactivation feedback dialog before the panel with the deactivation reasons is shown.

pending_activation_message

Customizes the message shown when activation is pending (when it requires completion by clicking an activation link sent via email).

is_submenu_visible

Controls the visibility of specific submenus for the product.

plugin_icon

Sets the icon displayed for the product. This affects the icon on the activation page, pricing page, and the updates section.

show_trial

Helps determine whether the Free Trial tab or the trial promotion admin notice should be shown.

is_pricing_page_visible

Controls the visibility of the pricing link for the product.

Actions Hooks

Actions enable developers to execute custom code at specific points during the product’s execution. To add an action, use the following method from the Freemius instance:

my_fs()->add_action(
  string $tag,
  callable $function_to_add,
  $priority = 10,
  $accepted_args = 1
);

This method’s signature is also similar to WordPress’ add_action function. The following actions are available:

after_license_change

Executed after a license change occurs.

after_plans_sync

Runs after the product’s plans are synchronized with Freemius.

after_account_details

Triggered after account details on the “Account” page are outputted (before the billing and payments sections).

after_account_user_sync

Executed after user account synchronization.

after_account_plan_sync

Runs after account plan synchronization.

before_account_load

Triggered before an account is loaded.

after_account_connection

Executed after a successful activation connection (when an account is successfully created).

account_email_verified

Triggered when an account email address is verified.

account_page_load_before_departure

Executed before finishing the loading of the Account page.

before_account_delete

Runs before an account is deleted.

after_account_delete

Executed after an account is deleted.

sdk_version_update

Triggered after the SDK version is updated.

plugin_version_update

Executed after the product version is updated.

initiated

Runs after the Freemius SDK is initialized.

after_init_plugin_registered

Runs after the Freemius SDK is initialized and the user is registered.

after_init_plugin_anonymous

Runs after the Freemius SDK is initialized and the user is anonymous.

after_init_plugin_pending_activations

Runs after the Freemius SDK is initialized and the user’s activation is pending confirmation.

after_init_addon_registered

Runs after the Freemius SDK is initialized for an add-on and the user is registered.

after_init_addon_anonymous

Runs after the Freemius SDK is initialized for an add-on and the user is anonymous.

after_init_addon_pending_activations

Runs after the Freemius SDK is initialized for an add-on and the user’s activation is pending confirmation.

after_premium_version_activation

Triggered after a premium version of the product is activated.

after_free_version_reactivation

Executed after reactivating the free version of the product.

after_uninstall

Runs after the product is uninstalled.

before_admin_menu_init

Runs before the product’s menu and submenus are added.

Checking if a hook is registered

Just like in WordPress core, the Freemius SDK instance provides a has_filter() method, which you can use to check whether a specific hook has been registered. This works for both actions and filters. The method signature is:

my_fs()->has_filter(
  string $tag,
  callable|bool $function_to_check
);

You can omit the second parameter to check for any registered filter or action.