Emlog添加限制用户必须登录才能查看文章内容方法

在写文章时候,为了更好的保护原创资源、提升网站会员数量,很多网站都会将部分精品内容进行隐藏,用户必须登录才能查看这部分隐藏的内容,现在就来为大家分享一个EMLOG限制用户必须登录才能查看部分文章内容的方法。
添加方法:
1、下载模板文件module.php,在文件中合适的位置添加如下代码
<?php function slyc($content){ if(preg_match_all('/<yc>([sS]*?)</yc>/i', $content, $hide_words)){ if(ISLOGIN ){ $content = str_replace($hide_words[0], $hide_words[1], $content); }else{ $hide_notice = '<div style="text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;">您必须先<a href="'.BLOG_URL.'admin">登录</a>才能查看隐藏内容</div>'; $content = str_replace($hide_words[0], $hide_notice, $content); } } return $content; } ?>2、打开模板文件echo_log.php,找到如下代码
<?php echo $log_content; ?> 将上述代码替换为下面的代码,保存 <?php echo slyc($log_content); ?>3、在编辑文章的时候,只需要切换到HTML模式,在要隐藏的内容前后分别添加隐藏代码即可,比如
<yc> 此处是要隐藏的内容 </yc>




本文作者:醉清风
文章标题: Emlog添加限制用户必须登录才能查看文章内容方法
本文地址:http://www.ndxy.cc/?post=33
版权声明:若无注明出处,本文皆为“七十二棵棕树-让信仰走进生活。”原创,转载请保留文章出处。
本文地址:http://www.ndxy.cc/?post=33
版权声明:若无注明出处,本文皆为“七十二棵棕树-让信仰走进生活。”原创,转载请保留文章出处。

