设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 1717|回复: 4
收起左侧

Discuz! X 用户上传头像后任务、系统页面、插件无法识别(检测不到)的解决办法

[复制链接]
发表于 2019-5-15 21:52:59 | 显示全部楼层 |阅读模式
用户头像由变量 $_G['member']['avatarstatus'] 检测是否存在,用户上传头像后未对 pre_common_member 表的 avatarstatus 字段置1,造成了已上传头像的用户无法发帖、任务、插件无法识别到头像的主要原因。

打开文件 home.php 查找:
  1. $discuz->init();
复制代码

下行加入以下代码(检测到3个大中小头像同时存在后,将 avatarstatus 字段置1):


  1. if($_G['mod'] == 'spacecp' && $_GET['ac'] == 'avatar' && $_G['uid'] && !$_G['member']['avatarstatus']){
  2. $avatar_root = str_replace('\\','/',DISCUZ_ROOT.'uc_server/data/avatar/');
  3. function get_avatar($uid, $size = 'middle', $type = '') {
  4.         $size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
  5.         $uid = abs(intval($uid));
  6.         $uid = sprintf("%09d", $uid);
  7.         $dir1 = substr($uid, 0, 3);
  8.         $dir2 = substr($uid, 3, 2);
  9.         $dir3 = substr($uid, 5, 2);
  10.         $typeadd = $type == 'real' ? '_real' : '';
  11.         return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).$typeadd."_avatar_$size.jpg";
  12. }
  13.         if(
  14.         file_exists($avatar_root.get_avatar($_G['uid'],'big')) &&
  15.         file_exists($avatar_root.get_avatar($_G['uid'],'middle')) &&
  16.         file_exists($avatar_root.get_avatar($_G['uid'],'small'))

  17.         ){
  18.                 C::t('common_member')->update($_G['uid'],array('avatarstatus' => 1));
  19.         }
  20. }

复制代码

发表于 2019-5-15 23:21:33 | 显示全部楼层
一定要对症下药
发表于 2019-5-16 21:18:04 | 显示全部楼层
楼上回答正解
您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-19 21:38 , Processed in 0.672038 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表