在 WordPress 页面的评论块中,如果用户未注册,则会要求他注册才能发表评论
<?php
comment_reply_link(array(
'reply_text' => __('Reply', 'am'),
'depth' => $depth,
'max_depth' => $args['max_depth'],
'login_text' => __('Log in to Reply', 'am'),
'before' => '',
));
?>
问题是如何,而不是将用户引导到页面
<a rel="nofollow" class="comment-reply-login" href="https://test.local/wp-login.php?redirect_to=https%3A%2F%2Fausuppreview-dev.local%2Freview%2Ftest-company-1%2F">Log in to Reply</a>
将自定义页面的地址放在href中?例如,/register/
我通过钩子过滤器尝试过
function custom_comment_reply_link($link, $args, $comment, $post) {
if (!is_user_logged_in()) {
$link = str_replace('wp-login.php', 'register', $link);
}
return $link;
}
add_filter('get_comment_reply_link', 'custom_comment_reply_link', 10, 4);
没用。
必须这样做。
但在您的版本中,过滤器的名称不正确。不是
A