can I pass arguments to my function through add_action?

后端 未结 13 2166
慢半拍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条回答
  •  萌比男神i
    2020-11-29 01:20

    I ran into the same issue and solved it by using global variables. Like so:

    global $myvar;
    $myvar = value;
    add_action('hook', 'myfunction');
    
    function myfunction() {
        global $myvar;
    }
    

    A bit sloppy but it works.

提交回复
热议问题