Emlog文章内容登录可见

2022年3月25日16:08:30 发表评论 688 views
操作步骤:

1、在当前使用主题的module.php文件添加以下代码:

function slyc($content){
	if(preg_match_all('/<yc\>([\s\S]*?)<\/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>,如:

<yc>
此处是要隐藏的内容
</yc>

 

历史上的今天:


欢迎来到菜鸟头头的个人博客
本文章百度已收录,若发现本站有任何侵犯您利益的内容,请及时邮件或留言联系,我会第一时间删除所有相关内容。

  • A+
所属分类:WEB

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: