Answer the question
In order to leave comments, you need to log in
How to show a post on the site after adding a comment in WordPress?
How to display a message like this to the user after adding a comment in WordPress :
Thanks, your comment has been added! After moderation, it will appear on the site!
add_action( 'comment_post', function ( $comment_ID, $comment_approved ) {
add_action( 'comment_form_before', function() {
echo '<h1>Спасибо, ваш комментарий добавлен! После модерации он появится на сайте!</h1>';
});
}, 10, 2 );
Answer the question
In order to leave comments, you need to log in
So far I had to stupidly do this:
add_action( 'comment_form_before', function() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
re = /comment-\d+/i;
url = window.location.href;
var hash = url.substring(url.indexOf("#")+1);
if (hash.match(re)) {
jQuery([document.documentElement, document.body]).animate({
scrollTop: $("#before_comment_form_box").offset().top - 50
}, 2000);
}
});
</script>
<div id="before_comment_form_box">
Спасибо! Ваш комментарий будет опубликован после проверки модератором.
</div>
<?php
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question