WPDev.one
Core Function
View Source on Trac ↗

add_action()

add_action( mixed $hook_name, mixed $callback, mixed $priority = 10, mixed $accepted_args = 1 )

Adds a callback function to an action hook.

Parameters 3 required

Name / Type Description
$hook_name
string

The name of the action to add the callback to.

Required
$callback
callable

The callback to be run when the action is called.

Required
int

$priority Optional. Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. Default 10.

Required
$accepted_args
int

Optional. The number of arguments the function accepts. Default 1.

Return Value

(true)
Always returns true.

Function Information

Since Version
1.2.0
Source File
wp-includes/plugin.php
Advertisement