Figured it out. Looking at wp-comments-post.php there is a filter called comment_post_redirect
which I used to check if the comment was approved and then added a query string to the URL. So easy.
//A query string needs to be added when redirecting back to the post after a comment is posted and not approved. This ensures the page with the "Your comment is awaiting moderation." message won't be cached by the CDN and seen by the rest of the world.
function add_query_string_to_comment_redirect($location, $comment) {
if( !$comment->comment_approved ) {
$location = add_query_arg( array( 'moderated' => '' ), $location);
}
return $location;
}
add_filter('comment_post_redirect', 'add_query_string_to_comment_redirect', 10, 2);
Related Posts:
- How to change the email notification recipient (user) for new comments?
- 3 moderators to approve comment
- How to auto-approve internal pingbacks?
- Exclude internal links from comment moderation?
- Multiple Comment Moderators and Notifications
- Add delete, approve, spam Links to Comments
- Get the number of comments awaiting moderation
- Capability for allowing user to post own comments without moderation
- Why do comment moderators need to have all create/edit/delete toboth posts and pages?
- Community Moderation Plugin for Comments [closed]
- Allow contributors to moderate comments comments on posts they write
- Hold comments for moderation only if user is not logged in
- show if comment is in moderation
- Reject Comments Based on Author Email
- Author can only see own post comment and can moderate
- How to moderate (manually approve) comments of a specific (registered) User
- WordPress comments – how to check if comment still needs to be approved?
- Why does akismet prevent jetpack comments from appearing in my moderation queue? [closed]
- How Do I Allow Comment Moderation for Other User’s Posts?
- Sending comment notifications to different recipients depending on taxonomy terms
- Who approved a comment, to show up in dashboard
- Can I allow registered users to comment without being logged in or having to be approved?
- Comment moderation
- Disable comment moderation in multisite
- Comment Blacklist
- Embed a page within WordPress dashboard?
- comment awaiting moderation
- Customize the new comment notifications sent to the post author after the comment is approved
- Disable comments on all posts/pages
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- Linking to Page Showing Only Comments Without Parent Post
- Comments screen in backend, how to disable email address of commenter for non admins
- Post Comments using WP REST API v2 in WordPress
- Show content only if member left a comment
- Parent comment’s author name
- get_comments_number of depth-1 (Level 1) (1 post)
- Using filter to add additional fields to comment_form()
- Disable wordpress comments API
- List Recent Comments from Across a Multi-site Network
- Number of External Links in Comments – Moderation Option
- Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
- Get most active users sort by comment count
- Passing arguments to wp_list_comments callback function
- What are the additional fields in wp_comments used for?
- Enable Recent Comments widget to display comments on attachment posts
- Change allowed HTML tags for comments
- comments_template not working correcly in custom template files
- On WordPress 4.4, how to get the post id using the comment_post hook
- How to change style of Disqus comment count on main page
- Adding another arg to comments_popup_link
- Exclude Duplicate Posts in this SELECT Query
- List User Comments on User Profile BuddyPress [closed]
- Exclude child comments in get_comments() or WP_Comment_Query?
- How to allow more HTML tags in comment for a certain comment_type
- How to deal with spam comments and distinguish them from non-spam comments?
- Can’t seem to get this CSS to work…any ideas why? [closed]
- Change order of comment fields
- comment_post action hook running on page load instead of after a comment is posted
- Same email for all comments
- Comments system doesn’t like International domains
- How do I reply to comments from admin panel on a tablet PC?
- Disable comments for a user? [closed]
- Polls with respective comments?
- Problem with WordPress Comment
- Where are comment ratings stored?
- Comments change the template name
- I can’t post comment via REST API
- how to SELECT for the current post id?
- WordPress scruity issue – Totally disable all comments by CSS — secure enough?
- wp_new_comment requires author url and author email
- How to save comment name email url fields?
- How to display the user’s comment status on the front end
- get_comments_number() vs. get_post_field( ‘comment_count’, ID )
- Where are comments coded when using custom theme?
- What is the point of get_comment_count() if you cannot limit by a comment type?
- Wrong IP address in comment section
- Comments turned off, but ‘Leave a reply’ link still there [duplicate]
- How to output number of comments with link to comments
- How do I make Twenty Ten display comments on the home page?
- Sort post comments from newest to oldest in pagination
- Get all comments associated with a specific page ID (comment_post_ID)
- How do I add custom field to Admin comment form and display
- I would like to count number of comments after 5 days ago
- Using Disqus with headless WordPress setup?
- Attaching author tag to the comment
- How to show a “Comments Are Closed” message on posts where comments have been closed?
- Necessary to have a comments.php if there are no comments?
- Comments pagination on author page
- Comments page id wp_list_comments
- Inserting comments via a procedure
- Can I use WP comments for custom tables?
- How can I have a full comments.php for an easy editing of all its aspects?
- Transfer comments from one domain to another
- WordPress is adding above html
- Passing user meta through comment form
- Display DISQUS on homepage
- How to stop a specific person to comment on my blog? [closed]
- WordPress Editor widgets “comments” and “post comments form” getting disappeared with elementor [closed]