You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:WordPress中PeepSo插件注册页用户名数字格式限制失效

Fixing Pure Numeric Username Restriction for PeepSo Registration Page

Hey there! I totally get where you're coming from—WordPress default registration plays by its own rules, but PeepSo runs its own independent registration system, which is why your existing restriction doesn't carry over. Let's walk through two simple, beginner-friendly solutions to fix this:

Option 1: Add Custom Code to Enforce the Restriction

PeepSo lets us hook into its form validation process with custom code. You can add this snippet to your theme's functions.php file (pro tip: use a child theme so your changes don't get erased when your theme updates) or a basic custom plugin:

// Force pure numeric usernames on PeepSo registration
add_filter('peepso_form_errors_register', 'enforce_numeric_peepso_username');

function enforce_numeric_peepso_username($errors) {
    // Grab the submitted username from PeepSo's form
    $username = isset($_POST['username']) ? trim($_POST['username']) : '';

    // Check if the username isn't empty and isn't only numbers
    if (!empty($username) && !ctype_digit($username)) {
        // Add an error message that will show up on the registration page
        $errors[] = __('Username must contain only numbers.', 'your-theme-text-domain');
    }

    return $errors;
}

Just swap 'your-theme-text-domain' with your theme's actual text domain (you can find this at the top of your theme's style.css file).

Option 2: Use PeepSo's Built-in Validation (No Code Required)

If you'd rather skip coding, check if your PeepSo version has built-in field validation:

  • Head to your WordPress admin → PeepSo → Configuration → Registration
  • Look for the "Username" field settings (it might be under "Custom Fields" or directly in the registration form setup)
  • Find an option like "Validation Rule" or "Regular Expression"
  • Set the regex to ^[0-9]+$—this tells PeepSo to only accept numbers for usernames
  • Save your changes and test the form

Quick Checks to Ensure It Works

  • Clear your site's cache (if you use a caching plugin) to make sure new rules take effect
  • Test the PeepSo registration page in an incognito window to avoid cached form data
  • Try submitting a username with letters or symbols to confirm the error message appears

内容的提问来源于stack exchange,提问作者Pawan Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:20:23