Php wordpress如何仅为登录用户添加帖子评论?
wordpress中的帖子如何仅为登录用户添加评论 访问者必须回答自己的插件评论。但我需要一个帖子,只为登录用户留下评论,用户必须先注册到站点,然后才能强制向帖子添加评论 可以用函数文件来做吗 我发现2个代码不起作用,不知道如何使用: 在facing link中找到以下内容: 代码: 在facing link中可以找到以下内容: 代码: 从这两个结合在一起,我建立了下面的功能Php wordpress如何仅为登录用户添加帖子评论?,php,wordpress,function,comments,hook,Php,Wordpress,Function,Comments,Hook,wordpress中的帖子如何仅为登录用户添加评论 访问者必须回答自己的插件评论。但我需要一个帖子,只为登录用户留下评论,用户必须先注册到站点,然后才能强制向帖子添加评论 可以用函数文件来做吗 我发现2个代码不起作用,不知道如何使用: 在facing link中找到以下内容: 代码: 在facing link中可以找到以下内容: 代码: 从这两个结合在一起,我建立了下面的功能 <?php $current_user = wp_get_current_user(); if ( 0 ==
<?php
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
// Not logged in.
'<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>'
} else {
// Logged in.
}
?>
并将此插件添加到我的帖子中,仅用于帖子
请帮我做这个。谢谢大家设置>讨论您会发现选项:用户必须注册并登录才能发表评论。-
选中此选项并保存将满足您要求的设置 查看下面的菜单导航
Settings >>> Discussion
Checked the "Users must be registered and logged in to comment " checkbox
非常感谢你。但只需要一个职位。帖子id。不是所有的帖子和页面都是逗号。非常感谢。但只需要一个职位。帖子id。并非所有帖子和页面都使用逗号。
<?php
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
// Not logged in.
'<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>'
} else {
// Logged in.
}
?>
Settings >>> Discussion
Checked the "Users must be registered and logged in to comment " checkbox