禁止查看用户个人资料。
规则profile.php。个人资料页面只能查看某些群组。
安装
打开engine / modules / profile.php文件并查找:
<span class="variable">$tpl</span>->compile(<span class="string">'content'</span>);
上面我们插入:
<span class="keyword">if</span> (<span class="variable">$is_logged</span> AND <span class="variable">$member_id</span>[<span class="string">'name'</span>] == <span class="variable">$row</span>[<span class="string">'name'</span>] OR <span class="variable">$member_id</span>[<span class="string">'user_group'</span>] == <span class="number">1</span>) {
<span class="variable">$tpl</span>->set(<span class="string">'[member_name]'</span>, <span class="string">""</span>);
<span class="variable">$tpl</span>->set(<span class="string">'[/member_name]'</span>, <span class="string">""</span>);
} <span class="keyword">else</span> {
<span class="keyword">if</span> (<span class="variable">$is_logged</span>) {
<span class="variable">$tpl</span>->set_block(<span class="string">"'\\[member_name\\](.<span class="variable">*?</span>)\\[/member_name\\]'si"</span>, <span class="string">""</span>);
msgbox(<span class="variable">$lang</span>[<span class="string">'all_info'</span>], <span class="string">"Вы можете просматривать только свой профиль!"</span>);
}
<span class="keyword">if</span> (!<span class="variable">$is_logged</span>) {
<span class="variable">$tpl</span>->set_block(<span class="string">"'\\[member_name\\](.<span class="variable">*?</span>)\\[/member_name\\]'si"</span>, <span class="string">""</span>);
msgbox(<span class="variable">$lang</span>[<span class="string">'all_info'</span>], <span class="string">"У вас нет прав просматривать профиль!"</span>);
}
}
打开userinfo.tpl模板文件并包装整个内容:
<span class="attr_selector">[member_name]</span>
содержимое <span class="tag">userinfo</span><span class="class">.tpl</span>
<span class="attr_selector">[/member_name]</span>
如果我们想要指定特定的ID而不是组,我们会更改:
<span class="variable">$member_id</span>[<span class="string">'user_group'</span>] == <span class="number">1</span>
上
<span class="variable">$member_id</span>[<span class="string">'user_id'</span>] == <span class="number">1</span>
对于几个群体:
in_array(<span class="variable">$member_id</span>[<span class="string">'user_group'</span>], <span class="keyword">array</span>(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>,<span class="number">5</span>))
完成!