禹天 禹天 禹天 禹天
  • 导航首页
  • macOS
  • Windows
  • 学习笔记
  • 推荐好站
  • 用户登录
  • 关于我们
禹天 禹天
  • TAG标签
  • 文章归档
  • 博主推荐
  • 热点排行

Phpcms v9会员中心修改邮箱/密码分拆优化的方法

2020-11-25 15:59 / in 学习笔记 / 阅读量:189 / TAG phpcms

用过Phpcms v9会员中心的朋友可能会发现:默认Phpcms v9会员中心的账号管理里边的【修改邮箱/密码】是放在一个页面内,于是会在如果不用修改密码只是要修改邮箱的情况出现一些困扰,比较久没写原装教程了,今天CMSYOU在这里与大家分享Phpcms v9会员中心修改邮箱/密码分拆优化的方法!

先来了解下Phpcms v9默认会员中心的账号管理里边的修改邮箱/密码页面:

20191025114947590.jpg


有些会员可能在这里修改的就会碰到疑问:修改邮箱的同时怎么还需要修改密码?

基于此,很有必要把修改邮箱和修改密码分拆,避免一些不需要的麻烦。

Phpcms v9会员中心修改邮箱/密码分拆优化的方法:

1、修改phpcms/modules/member/index.php中的account_manage_password方法:

$updateinfo = array();

if(!is_password($_POST['info']['password'])) {

showmessage(L('password_format_incorrect'), HTTP_REFERER);

}

if($this->memberinfo['password'] != password($_POST['info']['password'], $this->memberinfo['encrypt'])) {

showmessage(L('old_password_incorrect'), HTTP_REFERER);

}

 

//修改会员邮箱

if($this->memberinfo['email'] != $_POST['info']['email'] && is_email($_POST['info']['email'])) {

$email = $_POST['info']['email'];

$updateinfo['email'] = $_POST['info']['email'];

} else {

$email = '';

}

if(!is_password($_POST['info']['newpassword']) || is_badword($_POST['info']['newpassword'])) {

showmessage(L('password_format_incorrect'), HTTP_REFERER);

}

$newpassword = password($_POST['info']['newpassword'], $this->memberinfo['encrypt']);

$updateinfo['password'] = $newpassword;

 

$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));

if(pc_base::load_config('system', 'phpsso')) {

//初始化phpsso

$this->_init_phpsso();

$res = $this->client->ps_member_edit('', $email, $_POST['info']['password'], $_POST['info']['newpassword'], $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);

$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));

if ($res < 0) showmessage($message_error[$res]);

}

 

showmessage(L('operation_success'), HTTP_REFERER);


修改为:

$updateinfo = array();

if(!is_password($_POST['info']['newpassword']) || is_badword($_POST['info']['newpassword'])) {

showmessage(L('password_format_incorrect'), HTTP_REFERER);

}

if(trim($_POST['info']['newpassword']) != trim($_POST['info']['renewpassword'])) {

showmessage(L('passwords_not_match'), HTTP_REFERER);

}

$newpassword = password(trim($_POST['info']['newpassword']), $this->memberinfo['encrypt']);

$updateinfo['password'] = $newpassword;

 

$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));

if(pc_base::load_config('system', 'phpsso')) {

//初始化phpsso

$this->_init_phpsso();

$res = $this->client->ps_member_edit($this->memberinfo['username'], $this->memberinfo['email'], '', $_POST['info']['newpassword'], $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);

$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));

if ($res < 0) showmessage($message_error[$res]);

}

 

showmessage(L('operation_success'), HTTP_REFERER);


这一步中,将原有的account_manage_password方法简化,做成只修改会员密码。

2、配套修改前台模板文件:templates/cmsyou(你用的模板的目录)/member/account_manage_password.html,将邮箱那一栏的input去掉,具体代码请自己尝试修改,这里不给出具体代码。

修改后的会员中心修改密码页面

微信图片_20201125160124.png


3、在phpcms/modules/member/index.php中新增account_manage_email方法,用于单独修改email:

public function account_manage_email() {

if(isset($_POST['dosubmit'])) {

$updateinfo = array();

 

//修改会员邮箱

if($this->memberinfo['email'] != $_POST['info']['email'] && is_email($_POST['info']['email'])) {

$email = trim($_POST['info']['email']);

$updateinfo['email'] = $_POST['info']['email'];

}elseif($this->memberinfo['email'] == $_POST['info']['email']) {

showmessage(L('email_same'), HTTP_REFERER);

} else {

showmessage(L('email_format_incorrect'), HTTP_REFERER);

}

$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));

if(pc_base::load_config('system', 'phpsso')) {

//初始化phpsso

$this->_init_phpsso();

$res = $this->client->ps_member_edit($this->memberinfo['username'], $email);

$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));

if ($res < 0) showmessage($message_error[$res]);

}

 

showmessage(L('operation_success'), HTTP_REFERER);

} else {

$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;

$siteinfo = siteinfo($siteid);

 

//SEO

$SEO = seo($siteid);

if(!$setting['meta_title']) $setting['meta_title'] = '修改邮箱';

$SEO = seo($siteid, '',$setting['meta_title'],$setting['meta_description'],$setting['meta_keywords']);

 

$show_validator = true;

$memberinfo = $this->memberinfo;

 

include template('member', 'account_manage_email');

}

}


4、在会员模板目录templates/cmsyou(你用的模板的目录)/member/新增account_manage_email.html模板文件,模板的写法参考account_manage_password.html模板的写法,在这也不给出具体的代码了,请自行研究。修改后的会员中心修改Email页面至此,已经成功将修改邮箱/密码分拆,做到邮箱和密码单独修改。

微信图片_20201125160148.png



支付宝 微信
猜你喜欢
速学PHP视频教学,简单粗暴第二天
黑苹果之技嘉(GIGABYTE)主板BIOS设置篇
安装黑苹果建议的BIOS设置(基本原则)
给自己在线生成一个logo
评论 (0)
您只有登录后才可以评论~立即登录
暂无评论
Copyright @2019-2099 禹天的博客.All Rights Reserved 京ICP备12013512号-1 京公网安备11011502004272.
搜索
您将离开本站并访问