DedeCMS 內建問答模塊(/ask/)預設:
1. 必須登錄才能提問(未登錄跳轉登錄頁)
2. 提問消耗積分(匿名 10 分 + 懸賞分),積分不足報錯
目標:**匿名可提問、無積分門檻**。
ask/post.php// 原代碼
if (!isset($action)) $action = '';
if (empty($uid) && $action != 'rate') {
ShowMsg('請先登錄', '../member/login.php?gourl=../ask/');
exit();
}
// 修改為:直接註釋或刪除整個 if 塊
// if (!isset($action)) $action = '';
// if (empty($uid) && $action != 'rate') { ... }
注意:$uid 來自會員系統,註釋後匿名用戶 $uid 為空/0,下游邏輯需兼容。
// 原代碼
$needscore = $anonymous * 10 + $reward;
if ($scores < $needscore) {
ShowMsg('積分不足', '-1');
}
// 修改為:註釋或設為 0
// $needscore = $anonymous * 10 + $reward;
// if ($scores < $needscore) { ... }
// 或保留變量但歸零
$needscore = 0;
檢查同文件後續 INSERT INTO dede_ask 語句,確保 mid(會員 ID)、username 允許為 0/空:
$mid = $uid ? $uid : 0;
$username = $uid ? $cfg_ml->M_UserName : '匿名用戶';
模板文件 templets/plus/ask_post.htm(或對應風格目錄):
action="post.php"。/ask/post.php → 直接顯示提問表單,不跳轉登錄頁。mid=0、username='匿名用戶'。精確註釋 ask/post.php 中的 **登錄強制跳轉塊** 與 **積分門檻判斷塊**,同步調整模板與匿名字段兼容,即可實現「無需登錄、無需積分」的開放提問。生產環境務必加上反灌水措施。