看到/var/Widget/Register.php 文件中 41-47 行有:
/** 如果请求中有 password */
if (array_key_exists('password', $_REQUEST)) {
$validator->addRule('password', 'required', _t('必须填写密码'));
$validator->addRule('password', 'minLength', _t('为了保证账户安全, 请输入至少六位的密码'), 6);
$validator->addRule('password', 'maxLength', _t('为了便于记忆, 密码长度请不要超过十八位'), 18);
$validator->addRule('confirm', 'confirm', _t('两次输入的密码不一致'), 'password');
}
发现 Typecho 已经定义了。
这就很方便,我只用调用就好。
我们目前要实现的功能:
1.在表单中添加 input 让前台注册表单包含 password 和确认密码 confirm
2.接收请求时,如果请求中有 password 则设置,否则还是按照原来的样子使用随机字符串。
在表单中添加 input 让前台注册表单包含 password 和确认密码 confirm
接收请求时,如果请求中有 password 则设置,否则还是按照原来的样子使用随机字符串。
前台注册.php 内添加:
<p>
<label for="password" class="sr-only"><?php _e('密码'); ?></label>
<input type="password" id="password" name="password" placeholder="<?php _e('密码'); ?>" value="<?php echo $rememberPassword; ?>" class="text-l w-100" autofocus />
</p>
<p>
<label for="confirm" class="sr-only"><?php _e('重复密码'); ?></label>
<input type="password" id="confirm" name="confirm" placeholder="<?php _e('重复密码'); ?>" value="<?php echo $rememberConfirm; ?>" class="text-l w-100" />
</p>
在/var/Widget/Register.php 文件中,找到:
$generatedPassword = Typecho_Common::randString(7);
改成:
/** 如果请求中含有 password 则设置为密码,否则随机密码 */
if (array_key_exists('password', $_REQUEST)) {
$generatedPassword = $this->request->password;
}
else
{
$generatedPassword = Typecho_Common::randString(7);
}
到这里就已经修改好了,用户注册的页面 P 标签记得自己修改一下顺序!
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容