(integer) (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

$accepted_args

(integer) (optional) The number of arguments the function(s) accept(s). In WordPress 1.5.1 and newer hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run.

Default: 1

Return

The function returns true whether the attempted function hook fails or not. There is no test that the function exists nor whether the $function_to_add is even a string. It is up to you to take care and this is done for optimization purposes, so everything is as quick as possible.

Example

The filter img_caption_shortcode is applied in media.php using the following call:

Hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action 'comment_id_not_found' will pass the comment ID to each callback.

You can also pass an an anonymous function as a callback. For example:

Beware

If your version of PHP is older than 5.3.0, you can use create_function() [2] instead. But keep in mind that lambda functions created by create_function() are not cached by APC or any other optimizer [3]. So don't use create_function() if callback is supposed to be used more than few times or it has complex logic.