The woocommerce function woocommerce_account_orders($current_page) has 1 parameter called $current_page. The function is called via woocommerce_account_orders_endpoint via the following hook - add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' );

However, in the above hook, $current_page is not passed as an argument in the function. How is $current_page passed to woocommerce_account_orders() function?

1 Answer 1


Action hooks can pass variables do hooked callback functions. For example:

do_action( 'my_custom_action', $a_variable );

For that action, any callback function has access to $a_variable:

add_action( 'my_custom_action', 'my_custom_function' );

function my_custom_function( $a_variable ) {
     // etc.

The woocommerce_account_orders_endpoint action hook is defined like this:

do_action( 'woocommerce_account_' . $key . '_endpoint', $value );

Where $value would be passed to woocommerce_account_orders() which uses it as the $current_page argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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