wppaste
WordPress

has_action( string $hook_name, callable|string|array|false $callback = false, int|false $priority = false ): bool|int

Since
2.5.0, 6.9.0
Source
wp-includes/plugin.php:599
Checks if any action has been registered for a hook.

Description

When using the $callback argument, this function may return a non-boolean value that evaluates to false (e.g. 0), so use the === operator for testing the return value.

Parameters

$hook_namestring
The name of the action hook.
$callbackcallable|string|array|falseoptional
The callback to check for. This function can be called unconditionally to speculatively check a callback that may or may not exist. Default false.Default: false
$priorityint|falseoptional
The specific priority at which to check for the callback. Default false.Default: false

Return

bool|int
If $callback is omitted, returns boolean for whether the hook has anything registered. When checking a specific function, the priority of that hook is returned, or false if the function is not attached. If $callback and $priority are both provided, a boolean is returned for whether the specific function is registered at that priority.

Uses · 1

  • has_filter()Checks if any filter has been registered for a hook.

Used by · 28

Show all 28

Source

function has_action( $hook_name, $callback = false, $priority = false ) {	return has_filter( $hook_name, $callback, $priority );}

History

Introduced in 2.5.0. One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.9.7
Parameter $priority added.verified against source
6.9.0
Added the $priority parameter.from the docblock
2.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/plugin.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.