当前位置:首页 > 站长学院 > 建站教程 >

PHPCMSV9会员中心如何将邮箱和密码分开修改

作者:齐鲁建站    发布时间:2020-07-05    阅读:
使用过PHPCMSV9的朋友都知道,PHPCMSV9会员中心的密码和邮箱是在一起的,修改一个另一个也要跟着修改,那么PHPCMSV9会员中心如何将邮箱和密码分开修改呢,今天齐鲁建站小编就来说说PHPCMS邮箱和密码分开的方法。

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

PHPCMSV9会员中心如何将邮箱和密码分开修改

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

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

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

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去掉,具体代码请自己尝试修改,这里不给出具体代码。

PHPCMSV9会员中心如何将邮箱和密码分开修改

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模板的写法,在这也不给出具体的代码了,请自行研究。

PHPCMSV9会员中心如何将邮箱和密码分开修改

至此,已经成功将修改邮箱/密码分拆,做到邮箱和密码单独修改。

以上就是关于PHPCMS邮箱和密码分开的所有内容,有不懂的可加站长QQ交流哦。

QQ客服
QQ客服
陈经理