can I pass arguments to my function through add_action?

后端 未结 13 2182
慢半拍i
慢半拍i 2020-11-29 01:07

can I do something like that? to pass arguments to my function? I already studied add_action doc but did not figure out how to do it. What the exact syntax to pass two argum

13条回答
  •  野性不改
    2020-11-29 01:19

    If you want to pass parameters to the callable function, instead of the do_action, you can call an anonymous function. Example:

    // Route Web Requests
    add_action('shutdown', function() {
        Router::singleton()->routeRequests('app.php');
    });
    

    You see that do_action('shutdown') don't accept any parameters, but routeRequests does.

提交回复
热议问题