Discuz! X2修改注册用户名长度限制办理方案

  在新宣布的Discuz!X 2中,系统默认的用户名长度限制仍然是3-15字节,但有一些网站大概会因为各类原因需要将用户名长度的限制做一些修改。Discuz!X 1.5宣布时已有相关教程,不外进级Discuz!X 2后措施窜改较大,所以团结之前的一些履历,整理了这篇修改注册用户名长度的办理方案。具体操纵如下:

1、在网站/source/class/目次下的class_member.php文件中, 找到如下代码:

if($usernamelen < 3) { showmessage('profile_username_tooshort'); } elseif($usernamelen > 15) { showmessage('profile_username_toolong'); }

  个中的数值“15”为注册用户名长度的最大值,数值“3”为注册用户名长度的最小值。将这两个值改成你需要的数值即可,譬喻我的网站需要将注册用户名长度的最大值增大至20,以下均以此为例。则修改上面的代码为:

if($usernamelen < 3) { showmessage('profile_username_tooshort'); } elseif($usernamelen > 20) { showmessage('profile_username_toolong'); }

2、在网站/source/language/目次下的lang_message.php文件中, 找到如下代码:

'profile_username_toolong' => '歉仄,您的用户名高出 15 个字符,请输入一个较短的用户名',

修改为:

'profile_username_toolong' => '歉仄,您的用户名高出 20 个字符,请输入一个较短的用户名',

3、在网站/source/language/member/目次下的lang_template.php文件中, 找到如下代码:

'register_username_tips' => '用户名必需为大于3位小于15位',

修改为:

'register_username_tips' => '用户名由 3 到 20 个字符构成',

4、在网站/source/language/mobile/目次下的lang_template.php文件中, 找到如下代码:

'reg_username' => '用户名必需为大于3位小于15位',

修改为:

'reg_username' => '用户名由 3 到 20 个字符构成',

5、在网站/emplate/default/member/目次下的register.htm文件中, 找到如下代码:

<input autocomplete="off" class="px" id="{$this->setting['reginput']['username']}" maxlength="15" name="" required="" size="25" tabindex="1" type="text" />

修更名字输入框的限制字符数量“maxlength”,好比修改为:

<input autocomplete="off" class="px" id="{$this->setting['reginput']['username']}" maxlength="20" name="" required="" size="25" tabindex="1" type="text" />

6、在网站/uc_client/model/目次下的/user.php/文件中,找到如下代码:

?1 if($len > 15 || $len < 3 || preg_match("/s+|^c:concon|[%,*"s<>&]|$guestexp/is", $username)) {

修改为:

1 if($len > 20 || $len < 3 || preg_match("/s+|^c:concon|[%,*"s<>&]|$guestexp/is", $username)) {

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/10645.html