Action Hooks
Action hooks are designated points in the WordPress core, theme and plugin code where it is possible for outside resources (outside of the scope of where the hook is… either in the core, theme or plugin) to insert additional code and, there by, customize the code to do additional functions they may desire.
Actions Functions
add_action()
add_action( $hook, $function_to_add, $priority, $accepted_args );
$hook : (string) (required) The name of the action to which $function_to_add is hooked.
$function_to_add: (callback) (required) The name of the function you wish to be hooked.
$priority: (int) (optional) Used to specify the order in which the functions associated with a particular action are executed.
$accepted_args: (int) (optional) The number of arguments the hooked function accepts.
Examples
Simple Hook
function email_friends( $post_ID )
{
$friends = 'bob@example.org, susie@example.org';
wp_mail( $friends, "sally's blog updated", 'I just put something on my blog: http://blog.example.com' );
return $post_ID;
}
add_action( 'publish_post', 'email_friends' );