ecshop实现注册必须邮箱验证后登录
现在大多数正式运营的网站,注册都是必须进行邮箱(email)验证或者手机验证后才能注册成功或者成功登录的,那我们怎么通过ecshop二次开发来实现这样的功能呢?其实也比较简单,按照下面代码修改就能实现.
1、注册成功后台自动发邮件并退出登录状态,提示需要验证邮件才能登录,修改根目录下的user.php文件.把如下代码:
- $ucdata = emptyempty($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(!emptyempty($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('需要验证邮件才能登录', array($_LANG['back_up_page'], $_LANG['back_home_lnk']), array('user.php', 'index.php'), 'info');
购物流程时注册也要相应的修改,修改根目录下flow.php文件.
-
- if (register(trim($_POST['username']), trim($_POST['password']), trim($_POST['email'])))
-
-
- ecs_header("Location: flow.php?step=consignee\n");
- exit;
-
- $cfg = $_CFG['smtp_user'];
- if(!emptyempty($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('需要验证邮件才能登录', array($_LANG['back_up_page'], $_LANG['back_home_lnk']), array('flow.php?step=login', 'index.php'), 'info');