ECSHOP郵箱注冊(cè)驗(yàn)證后登錄
現(xiàn)在大多數(shù)正式運(yùn)營的網(wǎng)站,注冊(cè)都是必須進(jìn)行郵箱(email)驗(yàn)證或者手機(jī)驗(yàn)證后才能注冊(cè)成功或者成功登錄的,那我們?cè)趺赐ㄟ^ecshop二次開發(fā)來實(shí)現(xiàn)這樣的功能呢?其實(shí)也比較簡單,按照下面代碼修改就能實(shí)現(xiàn)。
1、注冊(cè)成功后臺(tái)自動(dòng)發(fā)郵件并退出登錄狀態(tài),提示需要驗(yàn)證郵件才能登錄。
修改根目錄下的user.php文件
把:
$ucdata = empty($user->ucdata)? "" : $user->ucdata;
show_message(sprintf($_LANG['register_success'], $username . $ucdata), array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act, 'user.php'),
'info');
替換成:
$cfg = $_CFG['smtp_user'];
if(!empty($cfg) )
{
$sql="select user_id from ".$GLOBALS['ecs']->table('users') ."where user_name = '$username'";
$user_id=$db->getOne($sql);
send_regiter_hash ($user_id);
}
$user->logout();
show_message('需要驗(yàn)證郵件才能登錄', array($_LANG['back_up_page'], $_LANG['back_home_lnk']), array('user.php', 'index.php'), 'info');
購物流程時(shí)注冊(cè)也要相應(yīng)的修改
修改根目錄下flow.php文件
查找:
if (register(trim($_POST['username']), trim($_POST['password']), trim($_POST['email'])))
將下面代碼:
/* 用戶注冊(cè)成功 */
ecs_header("Location: flow.php?step=consignee\n");
exit;
替換成:
$cfg = $_CFG['smtp_user'];
if(!empty($cfg) )
{
$sql="select user_id from ".$GLOBALS['ecs']->table('users') ."where user_name = '".trim($_POST['username'])."'";
$user_id=$db->getOne($sql);
send_regiter_hash ($user_id);
}
$user->logout();
show_message('需要驗(yàn)證郵件才能登錄', array($_LANG['back_up_page'], $_LANG['back_home_lnk']), array('flow.php?step=login', 'index.php'), 'info');