Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 2 years ago.
Improve this questionAs far as I understand about the action hook, add_action
is used to add callback functions to an exsiting action hook, which means, to make lines like
add_action('some_action_hook',function(){ // some function})
work, you need to have a line that says do_action some_action_hook
somewhere in your code. Is this understanding right?
I come across an action hook that I couldn't find where it is triggered: it is woocommerce's woocommerce_thankyou_bacs
. I've done a thorough text search inside my website root folder for woocommerce_thankyou_bacs
, the only line coming up is
add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) );
in \wp-content\plugins\woocommerce\includes\gateways\bacs\class-wc-gateway-bacs.php
.
I've also done a regex search for thankyou.*bacs
, the result is same. I also search this action hook online and in Woocommerce's documentation, but didn't get much useful informations.
This itself is trivial, but I'd like to know:
- Is the understanding that where there is a
do_action
, there must be a correspondingadd_action
correct, or at least generally correct? - If 1) is correct, what is the solid way to find where
do_action
is for a certain action hook?
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 2 years ago.
Improve this questionAs far as I understand about the action hook, add_action
is used to add callback functions to an exsiting action hook, which means, to make lines like
add_action('some_action_hook',function(){ // some function})
work, you need to have a line that says do_action some_action_hook
somewhere in your code. Is this understanding right?
I come across an action hook that I couldn't find where it is triggered: it is woocommerce's woocommerce_thankyou_bacs
. I've done a thorough text search inside my website root folder for woocommerce_thankyou_bacs
, the only line coming up is
add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) );
in \wp-content\plugins\woocommerce\includes\gateways\bacs\class-wc-gateway-bacs.php
.
I've also done a regex search for thankyou.*bacs
, the result is same. I also search this action hook online and in Woocommerce's documentation, but didn't get much useful informations.
This itself is trivial, but I'd like to know:
- Is the understanding that where there is a
do_action
, there must be a correspondingadd_action
correct, or at least generally correct? - If 1) is correct, what is the solid way to find where
do_action
is for a certain action hook?
1 Answer
Reset to default 2In WooCommerce (my version v6.1.1) there is a file called /woocommerce/templates/checkout/thankyou.php
and in line 79
you have trigger with dynamic payment method name so there is a place when each payment method do their magic
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
And answering your questions:
- The opposite. Where is
add_action
there is a correspondingdo_action
but i can be named dynamically just like we see it example above - There is no 100% way to find each
do_action
because all hook names depends on creativity of developer. So i can be hard to find at first glance just like example above
add_action( 'qjfberbierb fi', ...
is still perfectly valid even though I mashed my keyboard to get the action name and it will never be ran. – Tom J Nowell ♦ Commented Feb 11, 2022 at 19:16