Discuz論壇教程之修改注冊用戶名長度限制的方法。
在Discuz論壇中,系統默認的用戶名長度是 3-15字節,但有一些網站可能會因為各種原因需要將用戶名長度的限制做一些修改。所以結合之前的一些經驗,完成了修改 注冊用戶名長度 的辦法詳細如下:
1、修改注冊類和用戶名檢查提示
打開 /source/class/class_member.php 文件
找到
[php]view plaincopy
$usernamelen= dstrlen($username);
if($usernamelen< 3) {
showmessage('profile_username_tooshort');
} elseif($usernamelen> 15) {
showmessage('profile_username_toolong');
}
打開 /source/module/forum/forum_ajax.php 文件
找到
[php]view plaincopy
if($usernamelen< 3) {
showmessage('profile_username_tooshort', '', array(), array('handle'=> false));
} elseif($usernamelen> 15) {
showmessage('profile_username_toolong', '', array(), array('handle'=> false));
}
打開文件 uc_client/model/user.php
找到
[php]view plaincopy
functioncheck_username($username) {
$guestexp= '/xA1/xA1|/xAC/xA3|^Guest|^/xD3/xCE/xBF/xCD|/xB9/x43/xAB/xC8';
$len= $this->dstrlen($username);
if($len> 15 || $len< 3 || preg_match("//s+|^c://con//con|[%,/*/"/s/</>/&]|$guestexp/is", $username)) {
returnFALSE;
} else{
returnTRUE;
}
}
打開文件 static/js/register.js
找到
[php]view plaincopy
if(unlen < 3 || unlen > 15) {
errormessage(id, unlen < 3 ? '用戶名不得小于 3 個字符': '用戶名不得超過 15 個字符');
return;
}
把上面的15改成你需要的數字
2、修改語言包提示語句
打開 /source/language/lang_message.php 文件
找到
'profile_username_toolong' => '抱歉,您的用戶名超過 15 個字符,請輸入一個較短的用戶名',
把上面的15改成你需要的數字
打開 /source/language/mobile/lang_template.php 文件
找到
[php]view plaincopy
'reg_username'=> '用戶名必須為大于3位小于15位',
'registerinputtip'=> '用戶名:3-15位',
把上面的15都改成你需要的數字
到這里就全部改完了。
新聞熱點
疑難解答