If a theme and a plugin uses the same action hook, for example
comment_form is used by both theme and plugin. Then , which one will be called first? the function associated with the theme's hook or the function associated with the plugin's hook.
An action hook is simply a queue point that acts at a specific point in the PHP execution process: callbacks are queued via
add_action() call, and everything in the queue gets processed in turn:
add_action( 'hook_name', 'callback_name', $priority, $number_of_args );
A filter hook is a similar queue point, only it acts on a specific bit of data - it could be a string, an array, an integer, or whatever. As with actions, callbacks are queued via
add_filter() call, and everything in the queue gets processed in turn.
add_filter( 'hook_name', 'callback_name', $priority, $number_of_args );
If you need to ensure that one callback gets processed earlier or later than another, then you will need to ensure that the two callbacks have different priorities. The lower the number, the higher the priority, and the earlier the execution. The default priority is
10, so anything added with a priority of
11 will execute after the default, and anything added with a priority of
9 will execute before the default.
So, yes: both the Theme and Plugins can add action or filter callbacks to the same action/filter hook, without conflict.