問題描述

看看這些問題,但我找不到類似的問題。

我需要更改使用者嘗試使用錯誤的使用者名稱或密碼登入時顯示的自定義錯誤訊息。

喜歡,請改為:「錯誤:您為使用者名稱%1 $ s 輸入的密碼不正確,丟失密碼?到這個”Wrong information”(只是一個例子)

我嘗試使用”add_filter”,但我不熟悉它,所以,任何幫助將不勝感激!謝謝

最佳解決方案

您可以使用 login_errors 過濾器鉤來做到這一點,這裡是如何:

add_filter('login_errors','login_error_message');

function login_error_message($error){
    //check if that's the error you are looking for
    $pos = strpos($error, 'incorrect');
    if (is_int($pos)) {
        //its the right error so you can overwrite it
        $error = "Wrong information";
    }
    return $error;
}

更新:

我只是測試了程式碼,它工作正常,只是貼上在我的主題的 functions.php 檔案中的程式碼,而不用任何更改.po 檔案

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。