背景

Typecho前台登录/注册

1周前 typecho帮助 11°C

Typecho前台登录
前言
前台登录是个很方便的功能,无论是作为个人博客还是多人博客,前台登录都会节省用户时间。

代码

<form action="<?php $this->options->loginAction()?>" method="post" name="login" rold="form">
<input type="hidden" name="referer" value="<?php $this->options->siteUrl(); ?>">
<input type="text" name="name" autocomplete="username" placeholder="请输入用户名" required/>
<input type="password" name="password" autocomplete="current-password" placeholder="请输入密码" required/>
<button type="submit">登录</button>
</form>

其中 referer 这个input就指明了登录成功后的跳转位置,现在默认的首页,可以修改value的值来自行定义登录成功跳转得地址。

Typecho前台注册
代码

<form action="<?php $this->options->registerAction();?>" method="post" name="register" role="form">
<input type="hidden" name="_" value="<?php echo $this->security->getToken($this->request->getRequestUrl());?>">
用户名<input type="text" name="name">
邮箱:<input type="email" id="mail" name="mail" >
<button type="submit" name="loginsubmit" value="true">注册</button>
</form>

说明
用户进入注册页面,只会要求用户填写用户名和邮箱,点击注册按钮后会跳转到程序后台,此时会提示被分配了个临时密码,同时提示用户修改默认密码,填写个人信息如昵称,个人主页等。

扩展
如果也想像前台登录一样,登陆后自定义跳转页面,需要修改/var/Widget/Register.php这个文件,倒数第三行左右的这个代码$this->response->redirect($this->options->adminUrl);换成如下代码

if (NULL != $this->request->referer) {
$this->response->redirect($this->request->referer);
} else{
$this->response->redirect($this->options->adminUrl);
}

这样在form里插入

<input type="hidden" name="referer" value="跳转地址">
即可。

版权声明:小站所有内容均为互联网整理而来,仅供学习参考,如有侵犯您的版权,请联系删除。
本文链接:https://magicblue.cn/lost/15376.html
最后编辑: 23年09月15日

选择表情

网友评论

5个月前

所以说 这个主题官网挂了 应该在哪里买

6个月前

已经升1.2.1了

7个月前
头像 csp

抱抱

7个月前
头像 csp

有点惨啊

7个月前

支持支持一下