0
我已經在註冊表單中驗證了自定義字段,我宣讀了wordpress的註釋,以便我自己可以這樣做。但我知道它會拋出像這樣的錯誤在wordpress中註冊表單驗證
Call to a member function add() on a non-object
我不知道爲什麼會發生這種情況。我怎樣才能解決這個問題?任何建議都會很棒。
代碼:
function myplugin_check_fields($errors, $sanitized_user_login, $user_email) {
$errors->add('demo_error', __('<strong>ERROR</strong>: This is a demo error. Registration halted.','mydomain'));
return $errors;
}
add_filter('registration_errors', 'myplugin_check_fields', 10, 3);
使用全局代碼在這裏,似乎它知道添加,但它給了你一個錯誤,所以嘗試使一些變量全局變量與另一個頁面中的add()有關聯,檢查初始化 –