海狸网

  • 首页
  • 源码分享
    • APP源码
    • 商业源码
  • 主题插件
    • wordpress主题
    • wordpress插件
    • Typecho主题
    • Typecho插件
    • Zblog主题
    • Zblog插件
    • Emlog主题
    • Emlog插件
    • 苹果cms主题
    • 苹果cms插件
    • Discuzq
  • 系统软件
    • Windows平台
    • Mac平台
    • Android平台
    • Nas平台
    • VPS相关
    • 软件分享
  • 建站技巧
  • 视频推荐
  • 生活圈
  • 网址导航
海狸网
佛系博主,随缘更新,有事请留言。
  1. 首页
  2. 建站技巧
  3. 正文

typecho访问个人主页author无用户信息相关问题

2020年04月02日 162点热度 0人点赞 2条评论

author.php文件一般很少用到,先放出问题所在

访问用户a的个人主页,如果a发布过文章,则页面主页页面可以正常获取到a的邮箱,头像等相关信息

但是如果a没有发布过文章,则页面不能获取到相关个人信息,原因是获取并不到相关的用户id,但是浏览器的地址是带有用户的uid的,所以通过浏览器的地址,获取到用户uid,通过uid查询,反馈到页面中显示出用户相关信息

<?php 
if(empty($this->author->uid)){
$str=$_SERVER["REQUEST_URI"];
    if(preg_match('/\d+/',$str,$arr)){
       $id=$arr[0];
if ($this->user->hasLogin()&&$this->user->uid==$id){$lock=0;}else{$lock=1;}
$info=userok($id);
$this->user->uid=$id;
$this->user->screenName=$info['screenName'];
$this->user->mail=$info['mail'];
$this->user->group=$info['group'];
}
}
?>

判断用户uid是否存在,如果不存在,则获取浏览器的地址,读取uid,进行查询

function userok($id){
$db = Typecho_Db::get();
$userinfo=$db->fetchRow($db->select()->from ('table.users')->where ('table.users.uid=?',$id));
return $userinfo;
}

显示代码:

<?php $this->user->mail(); ?>
打赏赞微海报分享
本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: Typecho教程
最后更新:2020年11月02日

小海

打赏 点赞
< 上一篇
下一篇 >

文章评论

  • venlor without a prescription

    I enjoy you because of all of the effort on this blog. Betty delights in carrying out internet research and it's easy to see why. A lot of people hear all about the compelling form you convey advantageous guidance by means of the blog and attract contribution from other individuals about this area and my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You're carrying out a brilliant job.

    2021年01月10日
    回复
  • pamelor online

    I am commenting to let you know of the fabulous encounter my cousin's daughter experienced reading your site. She even learned many issues, not to mention what it's like to have a wonderful giving mindset to have many people just grasp chosen grueling subject areas. You really exceeded our expectations. Many thanks for distributing the informative, healthy, educational and as well as easy thoughts on the topic to Jane.

    2021年01月09日
    回复
  • 取消回复

    内容搜索

    小海狸

    保持饥渴的专注,追求最佳的品质

    毒鸡汤
    分类目录
    • APP源码
    • Mac平台
    • Nas平台
    • Typecho主题
    • Typecho插件
    • Windows平台
    • wordpress主题
    • wordpress插件
    • Zblog插件
    • 商业源码
    • 建站技巧
    • 生活圈
    • 苹果cms主题
    • 苹果cms插件
    • 视频推荐
    • 软件分享
    最新 热点 随机
    最新 热点 随机
    WordPress免费博客杂志主题CX-MULTI 推荐一款极简约的wordpress免费博客自媒体文艺主题下载 WordPress导航主题VIK Git:一款比付费主题更像是付费主题的WordPress免费主题 千面家园wordpress多行业主题-免费版 自适应wordpress电影电视网站中文免费主题模板
    推荐一款极简约的wordpress免费博客自媒体文艺主题下载WordPress免费博客杂志主题CX-MULTI
    影视资源采集站 WordPress主题 DUX 6.1 破解版 自用lsky-pro图床程序-支持第三方云储存,支持本地、阿里云OSS、腾讯云COS、七牛云、又拍云 【2020最新】全新改版影视系统源码(全开源) wordpress日主题(RiPro6.6)破解版独家修复明文完整版本 WordPress - 流行的建站程序介绍与下载
    标签聚合
    影视源码 wordpress主题 导航 苹果cms Typecho教程 苹果模板 Mac 影视CMS
    最近评论
    发布于 9 小时前(01月18日) Kaliteli işçilik ve hesaplı fiyatlarımız ile su de...
    发布于 9 小时前(01月18日) Kaliteli işçilik ve hesaplı fiyatlarımız ile su de...
    发布于 10 小时前(01月18日) <a href="http://propeciaff.com/">p...
    发布于 10 小时前(01月18日) <a href="http://retinabuy.com/">wh...
    发布于 10 小时前(01月18日) <a href="https://propeciaff.com/">...
    书签
    • 战东海
    • 海狸综合导航
    • 海狸网
    • 音乐搜索
    小姐姐

    COPYRIGHT © 2020 海狸网. ALL RIGHTS RESERVED.

    THEME KRATOS MADE BY VTROIS

    辽ICP备20001688号