在phpCMS v9系统中,如何让用户可以用email登录后台呢?参考本文介绍的方法,可以轻松实现这个功能。共分为二个步骤完成。
第一步:修改登陆的验证JS修改 statics/js/formvalidatorregex.js找到
<span style="font-size: 13px; font-family: 'courier new', courier;">ps_username:"^[\\u4E00-\\u9FA5\\uF900-\\uFA2D_\\w]+$" </span>
修改为:
<span style="font-size: 13px; font-family: 'courier new', courier;">ps_username:"^[\\u4E00-\\u9FA5\\uF900-\\uFA2D_\\w@\.]+$" </span>
第二步:修改登录文件
修改 phpcms/modules/member/index.php
1,找到
<span style="font-size: 13px; font-family: 'courier new', courier;">$synloginstr = ''; //同步登陆js代码 </span>
在下面添加:
<span style="font-size: 13px; font-family: 'courier new', courier;">preg_match('/^[a-z]+\w*@\w+\.[a-z0-9]{2,6}$/i', $username, $is_email);
</span>
2,找到下面的
<span style="font-size: 13px; font-family: 'courier new', courier;">$status = $this->client->ps_member_login($username, $password); </span>
修改为:
<span style="font-size: 13px; font-family: 'courier new', courier;">$status = $this->client->ps_member_login($username, $password, $is_email); </span>
3,找到下面的
<span style="font-size: 13px; font-family: 'courier new', courier;">$r = $this->db->get_one(array('username'=>$username));
</span>
修改为:
<span style="font-size: 13px; font-family: 'courier new', courier;">$r = $this->db->get_one(array($is_email ? 'email' : 'username'=>$username)); </span>
如此之后,便可以用Email能登陆了。快动手实践下吧。
The End

大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)