As 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:

  1. Is the understanding that where there is a do_action, there must be a corresponding add_action correct, or at least generally correct?
  2. If 1) is correct, what is the solid way to find where do_action is for a certain action hook?
  • the action name can be assembled using variables, it doesn't have to be a static string, the WooCommerce documentation is the most appropriate place to look for the answer here. Also, you can add a function to an action that never gets called, and you can fire an action that is never hooked into. 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
    Feb 11, 2022 at 19:16
  • Also, WooCommerce and other 3rd party plugin dev support questions are off topic here, this stack isn't a place to get help with WooCommerce
    – Tom J Nowell
    Feb 11, 2022 at 19:18

1 Answer 1


In 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:

  1. The opposite. Where is add_action there is a corresponding do_action but i can be named dynamically just like we see it example above
  2. 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

Not the answer you're looking for? Browse other questions tagged or ask your own question.