has_action()WP 2.5.0

Check if any action has been registered for a hook.

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.

1 time — 0.000016 sec (very fast) | 50000 times — 0.03 sec (speed of light)

No Hooks.


true|false|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.


has_action( $hook_name, $callback );
$hook_name(string) (required)
The name of the action hook.
The callback to check for. This function can be called unconditionally to speculatively check a callback that may or may not exist.
Default: false



#1 Check if the event init has hooks:

if( has_action( 'init' ) ){
	echo 'The `init` action has at least one function attached';

#2 Check if the event init has a specific function:

$priority = has_action( 'init', 'my_function' );

if( $priority ){
	echo "The init hook has my_function() attached with priority $priority";



Since 2.5.0 Introduced.

has_action() code WP 6.5.3

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