I am new to Wordpress/WooCommerce and PHP, although I have experience in other web platforms and languages. I have searched, but have not found the answer to my question which is...
Are hooks that are created by the "add_action" "added" to the list of actions called by that specific hook, or do they override any existing hooks of that action?
For example, if I add a woocommerce_thankyou
hook using:
add_action( 'woocommerce_thankyou', 'order_created_get_skus',#);
Question: Does this override any other hooks for woocommerce_thankyou
or does it get called in addition to any other hooks set for woocommerce_thankyou
?
Illustrated example:
In the below commented code example, you can see the execution order in the hook queue for each hooked function for the
woocommerce_thankyou
action hook:Lower priority is executed (or triggered) before, higher priority is executed (or triggered) after. If no priority is specified, the default priority is 10.
To see how many hooked functions are hooked on a specific hook with all necessary details, you can use the following that will give you a raw output:
There is 2 kind of hooks, as you have noticed may be, which are filter hooks and action hooks.
Action hook:
do_action()
add_action()
: the function is executed and can have optional arguments.Filter hook:
apply_filters()
add_filter()
: a mandatory argument (a variable) is filtered and returned from the "hooked" functionRelated: