^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助,如果有代码出错,请联系站长解决
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 腾讯云3年2核2G新品轻量限时特惠只需408元

WordPress评论回复可见

WordPress评论回复可见

功能代码:

2 核 2G 限时特惠 396 元/3 年    宝塔建站 10850 大礼包

//评论可见代码增强版,可镶嵌短代码
    function reply($content){
        if (preg_match_all('/<!--reply start-->([sS]*)<!--reply end-->/i', $content, $hide_words)){
        $stats = 'hide';
        global $current_user;
        get_currentuserinfo();
        if ($current_user->ID) {
            $email = $current_user->user_email;
        } else if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) {
            $email = $_COOKIE['comment_author_email_'.COOKIEHASH];
        }
        $ereg = "^[_.a-z0-9]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,5}$";
        if (eregi($ereg, $email)) {
            global $wpdb;
            global $id;
            $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_author_email = '".$email."' and comment_post_id='".$id."'and comment_approved = '1'");
            if ($comments) {
                $stats = 'show';
            }
        }
        $admin_email = "274728691@qq.com"; //博主 Email,博主直接查看  
        if ($email == $admin_email) {
            $stats = 'show';
            }
            $hide_notice = '<div style="text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;">温馨提示:此处内容需要<a href="'. get_permalink().'#respond" title="评论本文">评论本文</a>后,<a href="javascript:window.location.reload();" title="刷新">刷新本页</a>才能查看。</div>';
            if( $stats == 'show' ){
                $content = str_replace($hide_words[0], $hide_words[1], $content);
            }else{
                $content = str_replace($hide_words[0], $hide_notice, $content);
            }
        }
        return $content;
    }
    add_filter('the_content', 'reply');
//评论可见代码增强版,可镶嵌短代码结束

将博主的 email 处替换为自己的即可!

小雨帮大家整理了一些常见的隐藏内容的需求:

1、隐藏文章中部分内容,登陆后可见
2、隐藏文章中部分内容,评论可见
3、隐藏文章中部分内容,输入密码后可见
4、隐藏文章中部分内容,关注公众号后可见

你可以在下面这篇文章一次性 get 到高潮

WordPress如何做到限定用户阅读相关内容

今天在整理收藏夹的时候发现,以前收藏的一些文章站点打不开了,果然,个人站长越来越边缘化了,坚持下来的都是值得敬仰的,这让陌小雨萌生了一个想法,要不...

赠人玫瑰,手有余香。