所以我正在尋找一種方法來防止特定的電子郵件註冊我的網站上的帳戶。這是一個wordpress.org網站。防止特定的電子郵件註冊Wordpress.org
我試過Ban Hammer插件,但它不起作用。
我不是在尋找評論,但爲網站本身。就像我可以放在functions.php或某個地方的代碼一樣,當這個特定的電子郵件被用來嘗試和註冊我的網站上的帳戶,以獲得一個錯誤。
不是整個電子郵件域,例如@ gmail.com。但是一個特定的電子郵件,例如,[email protected]。
任何人都知道該怎麼做?
編輯:我發現這個教程在這裏:http://www.davidtiong.com/block-spam-registrations-on-wordpress/
我試圖在文件的最底部在functions.php中添加該文件正上方的最後>:
function dtwd_blocked_emails($user_email) {
$dtwd_blocked_list = array("[email protected]",);
$user_email_split = explode('@', $user_email); $user_email_domain = $user_email_split[1];
if (in_array($user_email_domain, $dtwd_blocked_list)) {
//Return 1, for detection
return 1;
} else {
//Return 0 for no detection
return 0;
}
}
?而且我還在我的主題的register.php中加入了這個:
elseif (dtwd_blocked_emails($user_email) == 1) {
$errors->add('blocked_email', __('<strong>ERROR</strong>: This email is not allowed.'));
}
而且我添加了相同的co de在我的主題login.php。
然後我嘗試註冊與此電子郵件帳戶(應該已被鎖住):[email protected]
該網站讓我註冊,它讓我登錄。該電子郵件現在應該已被阻止,並在我嘗試註冊和/或登錄時返回錯誤。
我不打算把它寫你...但你可以考慮掛鉤到像['registration_errors'](https://codex.wordpress.org/Plugin_API/Filter_Reference/registration_errors)動作鉤子,並在那裏做一些驗證。 – rnevius
恩,謝謝Rnevius。我正在查看你發佈的鏈接中的代碼,我認爲這就是我需要的,但我不知道如何爲我的需求製作代碼。任何機會,你可以......寫給我......盡我所能去問? – Overloard
我很樂意幫助你,但你需要先嚐試一下。如果仍然無法正常工作,請通過編輯發佈您嘗試過的(以及出現的問題)[最小,完整和可驗證的示例](http://stackoverflow.com/help/mcve)你原來的問題。 – rnevius