簡體   English   中英

Wordpress中的注冊表驗證

[英]Registration Form Validation in 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()實例的對象的全局權限global $wp_object_responsible;

    function myplugin_check_fields($errors, $sanitized_user_login, $user_email) {
        global $wp_object_responsible;  //edit here

$errors->add( 'demo_error', __('<strong>ERROR</strong>: This is a demo error. Registration halted.','mydomain') );

            return $errors;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM