Discuz论坛 X2-x3.4用户组到期后不自动切换解决教程

2019-10-22 2787 0条评论

打开文件:source/include/spacecp/spacecp_usergroup.php
找到代码


$groupexpirynew = $groupterms['ext'][$groupid];


替换为


$groupexpirynew = $groupterms['ext'][$extgroupidsnew];


然后找到代码


$expirylist[$group['groupid']]['grouptitle'] = in_array($group['groupid'], $expgrouparray) ? '<s>'.$group['grouptitle'].'</s>' : $group['grouptitle'];
                }
        }


在它的下面加上如下代码:



        if($expgrouparray) {

                $extgroupidarray = array();
                foreach(explode("\t", $_G['forum_extgroupids']) as $extgroupid) {
                        if(($extgroupid = intval($extgroupid)) && !in_array($extgroupid, $expgrouparray)) {
                                $extgroupidarray[] = $extgroupid;
                        }
                }

                $groupidnew = $_G['groupid'];
                $adminidnew = $_G['adminid'];
                foreach($expgrouparray as $expgroupid) {
                        if($expgroupid == $_G['groupid']) {
                                if(!empty($groupterms['main']['groupid'])) {
                                        $groupidnew = $groupterms['main']['groupid'];
                                        $adminidnew = $groupterms['main']['adminid'];
                                } else {
                                        $groupidnew = DB::result_first("SELECT groupid FROM ".DB::table('common_usergroup')." WHERE type='member' AND '".$_G['member']['credits']."'>=creditshigher AND '$credits'<creditslower LIMIT 1");
                                        if(in_array($_G['adminid'], array(1, 2, 3))) {
                                                $query = DB::query("SELECT groupid FROM ".DB::table('common_usergroup')." WHERE groupid IN (".dimplode($extgroupidarray).") AND radminid='$_G[adminid]' LIMIT 1");
                                                $adminidnew = (DB::num_rows($query)) ? $_G['adminid'] : 0;
                                        } else {
                                                $adminidnew = 0;
                                        }
                                }
                                unset($groupterms['main']);
                        }
                        unset($groupterms['ext'][$expgroupid]);
                }

                require_once libfile('function/forum');
                $groupexpirynew = groupexpiry($groupterms);
                $extgroupidsnew = implode("\t", $extgroupidarray);
                $grouptermsnew = addslashes(serialize($groupterms));

                DB::query("UPDATE ".DB::table('common_member')." SET adminid='$adminidnew', groupid='$groupidnew', extgroupids='$extgroupidsnew', groupexpiry='$groupexpirynew' WHERE uid='$_G[uid]'");
                DB::query("UPDATE ".DB::table('common_member_field_forum')." SET groupterms='$grouptermsnew' WHERE uid='$_G[uid]'");

        }


此方法适用于Discuz X2到X3.4,如果你的用户组到期可以正常切换就不需要进行以上修改,如果存在问题可以根据上面的丰富进行相应的调整,调整前请记住备份

文章版权及转载声明

本文作者:符文浩 网址:http://blog.fuwenhao.com/post/247.html 发布于 2019-10-22
文章转载或复制请以超链接形式并注明出处。

发表评论

快捷回复:

评论列表 (暂无评论,2787人围观)参与讨论

还没有评论,来说两句吧...

取消
微信二维码
微信二维码
支付宝二维码