禁止游客查看文章的一个插件,需要自己制作,本站仅提供源码:
<?php
/*
Plugin Name: Hide Posts from Guests
Description: This plugin hides post content from guests.
Version: 1.0
Author: OpenAI
*/
add_filter( 'the_content', 'hide_posts_from_guests' );
function hide_posts_from_guests( $content ) {
if ( !is_user_logged_in() ) {
return '抱歉,您必须登录才能查看内容。';
}
return $content;
}
使用方法:将这段代码保存到一个名为 hide-posts-from-guests.php 的文件中,并上传到您的WordPress站点的插件目录。然后,在WordPress后台激活插件即可。
略
插件信息
1. WordPress版本要求:5.6 or higher
2. PHP版本要求:5.6 or higher
3. 最新版本:5.6.0
4. 官网:
5. 作者:OpenAI
6. 语言:英文、简体中文
下载地址
登录WordPress后台 -> 插件 -> 安装插件 -> 搜索 “**” -> 启用
暂无评论内容