首页 > SEO优化 > typecho前台修改个人设置

typecho前台修改个人设置

时间:2023年10月19日 分类:SEO优化 浏览量:76

typecho皮肤中的author.php就是用户的个人中心,那么如何用它实现用户在前台修改个人信息呢?

出人意料的非常简单,只要把后台里面个人设置里面的这些代码搬进来就行了。

<section>
<h3><?php _e('个人资料'); ?></h3>
<ul><li>
<label class="typecho-label" for="screenName-0-1">
用户名</label><?php $this->user->name() ?></li></ul>
<?php Typecho_Widget::widget('Widget_Users_Profile')->profileForm()->render(); ?>
</sction>
<section id="change-password">
<h3><?php _e('密码修改'); ?></h3>
<?php Typecho_Widget::widget('Widget_Users_Profile')->passwordForm()->render(); ?>
</sction>
<?php Typecho_Widget::widget('Widget_Users_Profile')->personalFormList(); ?>

但是直接用的话,还要考虑一些事情,比如游客访问进来如果也这样显示岂不是很尴尬,A用户访问B用户时显示也会变尴尬,所以需要加入判断。

<?php if($this->user->uid==$this->author->uid && $this->user->hasLogin()): ?>
这里填写上边的代码即可,效果就是只有用户本人访问自己的个人中心,才会显示修改设置
<?php endif; ?>

代码中不含有样式,需要自己美化下,具体有什么效果,如下图所示:

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

标签: