🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

WordPress restricts the types of email addresses that can be registered (Email Allowlist and Blocklist)

Nowadays, more and more people are using WordPress to buildResource Download Sitesor foreign trade websites, many of which have enabled user registration. If you have checked the Admin Dashboard user list, you will find many accounts registered in bulk by bots, with email addresses from uncommon domain emails. We can use the following two methods to simply restrict the email service providers allowed during WordPress registration.

Registration Email Whitelist

For domestic users, it is recommended to use an email registration whitelist. Since your main users are Chinese, there are rarely registrations from users with those obscure domain emails. We can allow registration only from common email providers.Usage Method: Copy the code below and paste it into the website Theme's functions.php file.
/*
* WordPress注册邮箱白名单
* https://blog.naibabiji.com/skill/mail-registration-restrictions.html ‎
*/
function is_valid_email_domain($login, $email, $errors ){
$valid_email_domains = array("gmail.com","qq.com");// 允许注册的邮箱信息
$valid = false;
foreach( $valid_email_domains as $d ){
$d_length = strlen( $d );
$current_email_domain = strtolower( substr( $email, -($d_length), $d_length));
if( $current_email_domain == strtolower($d) ){
$valid = true;
break;
}
}
// if invalid, return error message
if( $valid === false ){
$errors->add('domain_whitelist_error',__( 'ERROR: 本站只支持gmail和QQ邮箱注册。' ));
}
}
add_action('register_post', 'is_valid_email_domain',10,3 );

Registration Email Blacklist

If you run a foreign trade website, you will encounter many registrations from foreigners. They might use some domain emails. We can check the registration records in the Admin Dashboard to determine which domain emails are from spam, and directly block registration from those domains. At this time, you can use the Ban Hammer Plugin, which can very conveniently help us set up a domain blacklist.Wordpress邮箱注册黑名单 Download LinkIn addition to email whitelists and blacklists, we can also add a simple registration verification to the website to prevent bulk registration by bots. For example, if you want to register for Naibabiji, you need to answer a question first to proceed.

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan to Follow