How to get current action? 时间:2013-02-18 作者:user1692333 我正在制作海关登记表。是否可以在函数中获取当前操作(添加注释或用户注册)?例如,我正在使用:add_filter(\'preprocess_comment\', \'checkQuestion\'); add_filter(\'registration_errors\', \'checkQuestion\', 10, 3); 所以,从函数checkQuestion 我想知道这叫什么动作? 2 个回复 SO网友:MEDZ 您可以简单地使用current_filter() WordPress功能。http://codex.wordpress.org/Function_Reference/current_filter SO网友:Cole 这可能是不可靠的,因为它取决于来自registration\\u errors过滤器的值,但希望您能理解。function checkQuestion($var1, $var2 = \'\', $var3 = \'\') { if(empty($var2) && empty($var3)) { // You are on the preprocess_comment filter because you did not receive a total of three variables } else { // You are on the registration_errors filter because $var2 and $var3 are not empty } return $var1; } 结束 文章导航