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; ?>

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

个人中心效果图.jpg

版权属于:泽泽社长
本文链接:https://blog.zezeshe.com/archives/typecho-personal-settings.html
本站未注明转载的文章均为原创,并采用 CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢!