最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

password - Function called by password_reset action passed only 1 argument instead of 2 in PHP 7.2.11

programmeradmin1浏览0评论

WordPress Version: 4.9.8

Note that the below happens only in PHP version 7.2.11 and in 7.0.32 it works fine!

password_reset action is suppose to call function with 2 arguments but I am getting this:

PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function changeServerPassword(), 1 passed in /home/hm/public_html/wp-includes/class-wp-hook.php on line 288 and exactly 2 expected in /home/hm/public_html/wp-content/plugins/[path].php:9, referer: .php?action=rp

So for some reason, it looks like WP is calling my function with only 1 argument. Any idea why this is happening? Following is a sample code that I am using:

add_action('password_reset', Array(new className(), "changeServerPassword"));

Inside the class className:

// $pass is not passed by wordpress and so it results in the above error
public function changeServerPassword($user, $pass) {
    // do things here
}
发布评论

评论列表(0)

  1. 暂无评论