在我的博客上有大量注册。是否禁用特定域?

时间:2015-06-19 作者:deadfish

从几天开始,每隔几分钟我就会在邮箱中找到新用户的信息。

我不知道这样做的主要目的是什么,但我假设有人在我的网站上检查了一些东西,但这并不好。

在用户填写电子邮件字段时,是否有可能禁用特定域?我应该担心吗?

enter image description here

1 个回复
最合适的回答,由SO网友:Robert hue 整理而成

顺便说一句,你可以试试这个。我只是整理了一些东西。它应该可以阻止gmail。com域。

当有人试图在您的网站上注册时,此功能将检查电子邮件域,如果电子邮件域匹配,则会抛出错误。

function wpse_disable_email_domain( $errors, $sanitized_user_login, $user_email ) {

    list( $email_user, $email_domain ) = explode( \'@\', $user_email );

    if ( $email_domain == \'gmail.com\' ) {
        $errors->add( \'email_error\', __( \'<strong>ERROR</strong>: Domain not allowed.\', \'my_textdomain\' ) );
    }

    return $errors;

}

add_filter( \'registration_errors\', \'wpse_disable_email_domain\', 10, 3 );

OK I just tested it and it\'s working.

结束

相关推荐