文章目录
本文最后更新于 2023-05-12,已超过 365 天未更新,内容可能已失效。

代码:

function limit_user_registrations_per_ip($errors, $sanitized_user_login, $user_email) {
    $ip = $_SERVER['REMOTE_ADDR'];
    $registered_users = get_users(array('meta_key' => 'ip_address', 'meta_value' => $ip));
    $allowed_users = 5; //设置每个IP地址允许注册的最大用户数量
    if(count($registered_users) >= $allowed_users) {
        $errors->add('ip_address_limit', __('Error: You have reached the maximum number of registrations from your IP address.'));
    }
    return $errors;
}
add_filter('registration_errors', 'limit_user_registrations_per_ip', 10, 3);

修改代码中的$allowed_users变量,设置每个IP地址允许注册的最大用户数量。

CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
文章链接:https://zptheme.com/6231.html
本文作者:ceshi·来源:子佩工作室

除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。

相关推荐

登录后即可发表评论

社交账号登录

全部评论 (1)