在网站/source/class/目录下的class_member.php文件中, 找到如下代码:
1 2 3 4 5 6 7 | if(!$activation) { $usernamelen = dstrlen($username); if($usernamelen < 4) { showmessage('profile_username_tooshort'); } elseif($usernamelen > 15) { showmessage('profile_username_toolong'); } |
其中:
1 | if($usernamelen < 4) { |
的4为最短用户名长度
1 | } elseif($usernamelen > 15) { |
15代表用户名长度限制为15
如果不想让用户使用手机号码注册,则可以将用户名最大长度限制为 “10”
此外还需要修改 static/js/register.js 中的用户名长度限制
找到:
1 2 3 4 5 | var unlen = username.replace(/[^\x00-\xff]/g, "**").length; if(unlen < 3 || unlen > 15) { errormessage(id, unlen < 3 ? '用户名不得小于 3 个字符' : '用户名不得超过 15 个字符'); return; } |
其中: if(unlen < 3 || unlen > 15) { 其中3代表最短用户名长度,15为最长用户名长度,将其修改,同时修改下方的提示文字,该提示文字用于注册页的ajax提示
修改其他三处文件的提示信息
在网站/source/language/目录下的lang_message.php文件中, 找到如下代码:
1 2 | 'profile_username_tooshort' => '抱歉,您输入的用户名小于 3 个字符,请输入一个较长的用户名', 'profile_username_toolong' => '抱歉,您的用户名超过 15 个字符,请输入一个较短的用户名', |
将提示信息的用户名长度修改为你修改的
手机版的提示文件
在网站/source/language/mobile/目录下的lang_template.php文件中, 找到如下代码:
1 | 'reg_username' => '用户名必须为大于3位小于15位', |
1 | 'registerinputtip' => '用户名:3-15位', |
依照自己设定的长度修改
在网站/source/module/forum/Forum_ajax.php 文件中, 找到如下代码:
1 2 3 4 5 6 7 | $username = trim($_GET['username']); $usernamelen = dstrlen($username); if($usernamelen < 3) { showmessage('profile_username_tooshort', '', array(), array('handle' => false)); } elseif($usernamelen > 15) { showmessage('profile_username_toolong', '', array(), array('handle' => false)); } |
原理同第一段