Without Ajax or plugins. Add to function.php:
add_action( 'set_comment_cookies', function( $comment, $user ) {
setcookie( 'ta_comment_wait_approval', '1' );
}, 10, 2 );
add_action( 'init', function() {
if( $_COOKIE['ta_comment_wait_approval'] === '1' ) {
setcookie( 'ta_comment_wait_approval', null, time() - 3600, "https://wordpress.stackexchange.com/" );
add_action( 'comment_form_before', function() {
echo "<p id='wait_approval' style="padding-top: 40px;"><strong>Your comment has been sent successfully.</strong></p>";
});
}
});
add_filter( 'comment_post_redirect', function( $location, $comment ) {
$location = get_permalink( $comment->comment_post_ID ) . '#wait_approval';
return $location;
}, 10, 2 );
Related Posts:
- How do we remove the H3 tag for the reply-title I.D
- Using filter to add additional fields to comment_form()
- How to add a div on comment fields / edited
- How to modify comments form using comment_form()?
- Comment form problem with comment_author_url and HTML5 input placeholders
- stackexchange-like submit comment window
- WordPress custom form action url
- After Submitting Comment Form Shows an Empy Page in WordPress
- Spammers attacking my WordPress Site – Removing URL field from core? [closed]
- Disable only the comment form/box itself?
- How to hide wordpress post comment form for specific role
- Copy and Paste Password for Comments
- How t Remove Labels from comment Box
- comment form code redirect to wp_comments_post.php with blank page
- Need to output comment_form() function inside a foreach loop
- How add custom text under comment form
- Delete comments function
- Image Upload Form is Disabling Comment Addition
- Comment submission & navigation redirects to default language
- Reply to a specific comment?
- How to hide the login / profile urls on top of comment box for a post
- How do I comment out a block of tags in XML?
- R: Comment out block of code
- How to enable comments for pending and draft posts?
- A plugin where users can comment with Facebook or Twitter or OpenID [closed]
- Reverse comment pagination numbers
- Comment Count for each Comment Author
- Multiple Comment Moderators and Notifications
- function to remove ‘comments and trackbacks are closed’
- Add a drop down list to comment form?
- How can I change the label “Comments” to “Review” everywhere in the WP installation without translation
- How to move comments form above comments list in wordpress
- Let user edit his own comment
- Get the number of comments awaiting moderation
- How can I automatically delete comments that contain chinese / russian signs?
- How to add enctype to multipart/form-data to comment form?
- Comments view limited to 20 results – any way to increase to 50 or 100?
- Changing position of cancel_comment_reply_link and other elements of comment form
- What does the “$depth” parameter in the Walker_Comment stand for?
- Why do comment moderators need to have all create/edit/delete toboth posts and pages?
- Comment pagination – How to show determined number of comments on the first page?
- How to allow a particular role like Contributor be able to only view pending comments and approve them?
- How do I really disable comments?
- Sort comments by karma
- Comment form connection to Gravity Forms
- Add classname comment template from functions.php
- Reject Comments Based on Author Email
- List user comments in author page
- Filter custom posts with / without comments
- Create comments.php form of custom HTML code
- Disqus comments and pingback script – how to change the order?
- To whom do emails get sent via the WordPress comments form?
- Is it possible to embed github gists in wordpress comments?
- Comments feed – Undefined named entity: ndash
- warnCommentChanges always being triggered on update
- how get comments only on post of current logged in user?
- How to get comment id in callback function?
- How to convert WordPress comments to bbPress replies [closed]
- Get declared variable in single.php to work in comments.php without re-declaring it [closed]
- What is causing wp-comments-post.php to redirect to the browser’s IP address?
- Extra Title field for Comments
- Comments offset
- comments_number not displaying
- Insert Ads “into” comments section in Genesis Themework
- WordPress Recent Comments Widget exclude own comments
- How to prevent multiple comments
- How to get comment images stored as serialized comment meta
- Hide comments on specific pages, not just disable future comments
- JQuery Counter Limit not working for WP Comment Textarea
- Additional content every x comments
- How to display category name from commenter’s custom post
- Add comment_meta to wp_comment_reply
- How do comments work?
- Can’t reply to comments [closed]
- What’s the difference with trash_comment and wp_trash_comment?
- How can i change the order of comments?
- ask and edit an extra comment field
- Refresh individual comment text via API
- How to filter comments by comment_meta
- Prevent users to delete comments from trash
- How to display replies to his comments in user profile of current user
- How do I refresh “Post Last Modified Time”, as long as comment is updated to Approve status?
- Top rated posts Average rating issue
- stop url changing when user comments
- Comment field override
- Badges for Guests based on their comment counts [closed]
- How to add a class to comment submit button?
- WordPress Comments – Only show part of user name
- Comments Template shows, but not the comments
- Broken comments section – WordPress 2014 Theme
- Need an advice about comments
- Force logged in users to provide more data when commenting
- How do I get the comments section to show up?
- By Default, Turn Comments Off for Pages & Leave Comments On for Posts
- same comment list for two posts
- Replace do_action() with a normal submit form in comments.php
- edit-comments.php in Admin – how to change ‘Comments’ title?
- Stop future commenting on specific post
- How to Allow Users to Select Recipients In a WordPress Comment section?
- comment_approved custom value