xxxxxxxxxx
// The action callback function.
function example_callback( $arg1, $arg2 ) {
// (maybe) do something with the args.
}
add_action( 'example_action', 'example_callback', 10, 2 );
/*
* Trigger the actions by calling the 'example_callback()' function
* that's hooked onto `example_action` above.
*
* - 'example_action' is the action hook.
* - $arg1 and $arg2 are the additional arguments passed to the callback.
do_action( 'example_action', $arg1, $arg2 );
add_action WordPress
xxxxxxxxxx
add_action('save_post_shop_order', 'my_callback_function');
function my_callback_function(){
// do your job
}
xxxxxxxxxx
add_action('wp_footer', function($arguments) use ($myvar) {
echo $myvar;
}, $priority_integer, $accepted_arguments_integer);
xxxxxxxxxx
// Hooks a function on to a specific action.
add_action( string $tag, callable $function_to_add, int $priority = 10,
int $accepted_args = 1 )