【问题标题】:Can i drop table wp_comments to prevent anyone's comment?我可以删除表 wp_comments 以防止任何人发表评论吗?
【发布时间】:2014-07-31 03:13:28
【问题描述】:

我在网络上有一个 Wordpress 网站。一些垃圾邮件发送者在我的 Wordpress 上发布了许多垃圾信息。我可以在我的 Wordpress 数据库中删除 wp_cmets 表吗?我不希望任何人发布 cmets。删除wp_cmets表会导致wordpress网站崩溃吗 drop table wp_comments 对我来说很好。

【问题讨论】:

  • 您可以从每个帖子和页面的“允许来自管理员端的评论”中删除勾选标记

标签: wordpress


【解决方案1】:

这是我过去使用过的一段代码。它会将用户重定向到您的 cmets 部分,并在您的后端隐藏该 cmets 部分。挑选并选择您想要的部分,并将它们放入主题的 functions.php 文件中。

// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
    $post_types = get_post_types();
    foreach ($post_types as $post_type) {
        if(post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
            remove_post_type_support($post_type, 'trackbacks');
        }
    }
}
add_action('admin_init', 'df_disable_comments_post_types_support');

// Close comments on the front-end
function df_disable_comments_status() {
    return false;
}
add_filter('comments_open', 'df_disable_comments_status', 20, 2);
add_filter('pings_open', 'df_disable_comments_status', 20, 2);

// Hide existing comments
function df_disable_comments_hide_existing_comments($comments) {
    $comments = array();
    return $comments;
}
add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);

// Remove comments page in menu
function df_disable_comments_admin_menu() {
    remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'df_disable_comments_admin_menu');

// Redirect any user trying to access comments page
    function df_disable_comments_admin_menu_redirect() {
    global $pagenow;
    if ($pagenow === 'edit-comments.php') {
        wp_redirect(admin_url()); exit;
    }
}
add_action('admin_init', 'df_disable_comments_admin_menu_redirect');

// Remove comments metabox from dashboard
function df_disable_comments_dashboard() {
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('admin_init', 'df_disable_comments_dashboard');

// Remove comments links from admin bar
function df_disable_comments_admin_bar() {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
}
add_action('init', 'df_disable_comments_admin_bar');

【讨论】:

    【解决方案2】:

    我想这会导致很多问题/错误。您最好从插入 cmets 的特定代码中禁用 cmets。

    您可以在找到wp_insert_comment($data); 的任何地方注释掉它,这样您就可以维护现有代码,以防万一有一天您想要它回来。

    【讨论】:

      【解决方案3】:

      我建议您使用Akismet 自动将 cmets 过滤成可能是真实的内容,而 99% 的内容可能只是指向狡猾网站的垃圾邮件链接,而不是从 wordpress 中删除评论表..

      删除表有时会导致很多问题..但是使用像 Akismet 这样的插件将是防止垃圾邮件 cmets 的最佳解决方案

      【讨论】:

      • OP 没有询问 如何 删除表格;他/她在问丢桌子是否会引起任何问题。
      猜你喜欢
      • 2017-06-17
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 2012-10-27
      • 2018-07-25
      • 1970-01-01
      • 2019-12-28
      • 2011-07-21
      相关资源
      最近更新 更多