Since the comment form is generated before the comment is submitted that won’t work too well logically.
The better option is comment_post_redirect
filter:
/**
* Filter the location URI to send the commenter after posting.
*
* @since 2.0.5
*
* @param string $location The 'redirect_to' URI sent via $_POST.
* @param object $comment Comment object.
*/
$location = apply_filters( 'comment_post_redirect', $location, $comment );
You can hook into it, check how many comments user has, and change the URL in $location
as necessary.
Related Posts:
- How to wrap submit button of comment form with div
- How can I limit the number of comments per registered user per day?
- Showing comments only to same custom user role
- How to hide “Trackback” on paginated comments
- how to have 2 comments_template() in one post
- Passing arguments to wp_list_comments callback function
- customize comment form
- comments_template not working correcly in custom template files
- How can I show comments in random order?
- How to get last comments but not from admin (or other specific user role/capability)?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, func
- What does the “$depth” parameter in the Walker_Comment stand for?
- Add classname comment template from functions.php
- Redirect to page 2 after comment
- Customizing comments pagination for bootstrap
- comment_post action hook running on page load instead of after a comment is posted
- using comments_template() in custom single-portfolio.php
- how to properly use comments-template.php
- WordPress comments – how to check if comment still needs to be approved?
- Modify WordPress Comment From For AMP Html
- Redirect when click on “response” in comment section
- Incorrect redirection after commenting on custom type
- What is causing wp-comments-post.php to redirect to the browser’s IP address?
- comments_number not displaying
- How to make comments private for commentor and post author
- Name of comment field differs on different sites
- The comment could not be saved. No comment_ID on comments
- How to display comment meta under each comment content
- How can I embed comments plugin to my own website?
- Custom comment field not showing when logged-in
- Custom comment link
- Re-Direct After Comment Submit IF Comment Comes from Sign-Up Page
- How to display replies to his comments in user profile of current user
- How to show a list of comments on home page from all posts?
- reply comment below the comment box without reload page
- How to call out the date of user’s first comment?
- How to pass settings to comment_form() if theme only uses comments_template()?
- How to add a class to comment submit button?
- How Can I display the Current Logged-In User’s Comment at the Top of the Comments Section in WordPress?
- Comments page id wp_list_comments
- reply to comment excerpt instead of author in comment title
- How to maintain changes to comment-template.php
- Display Comment Form on dedicated Page for each post
- Commentform – Hightlight invalid fields instead of prompting towards error page
- Auto approve all comments (editor)
- Comment submission & navigation redirects to default language
- The last comments of a post for the author of that post
- Add option to disable comments on a per posts basis?
- Check If comment author is registered
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Is there a hook for comment author link?
- How can I edit the email sent when a new comment is received?
- How to Block Access to Standard Login Flow and Comment Flow
- Prevent Contributor to show comment list
- where to modify get_comment_author_link()?
- Displaying comments with a walker: how to distinguish between parent and child comments
- Count parent comments & replies separately?
- Comment form problem with comment_author_url and HTML5 input placeholders
- How would I count the number of times a comment meta field’s value is in a post’s entire comments?
- stackexchange-like submit comment window
- Cannot get local avatars to show [closed]
- Limit user to one comment
- WordPress comments on users profile
- wordpress threaded comments – customize nested ul / how child ul is displayd
- How to make a secure blog that is completely private?
- identify and delete spam comments from 3000 pending comments
- Hide comments column in WordPress backend
- How unrequire comment text in wordpress post
- Auto delete comment if Contains
- API Hook for After Commenting (for sharing on Facebook)
- Can comments by a logged-in user be displayed at the top?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Placed on + only date (not time)
- Loading Comments From a Class?
- have_comments not true for logged out visitors?
- Anonymize comments after one year
- How many members have made comments approved for an article?
- How to get a value from comment meta
- Comment System showing different type of IP
- Only Allow post author and “Premium” Role user to comment
- Exclude the word comment from being referenced
- How to open up comments to all visitors
- What is the earliest hook comment meta can be saved?
- Is this a wordpress bug? get_comment_link auto shoots when user visits his dashboard
- Comment as post – understanding wp_list_comments
- Comments and pingbacks issues
- Cannot unapprove a WordPress comment
- how show attachment image in comments query
- Automatically register users with comments
- Comments only displaying when logged in
- Same comment section on every page
- Force to show all fields in comment forms to the logged-in users
- Unable to view comments on my website
- Using WordPress core pop-up comment function, doesn’t popup, maybe an elementor issue
- comment_moderation_subject is not working for me
- Posting XML in comment section
- Comments – Ensure the correct field is highlighted for nested replies
- How to hold all comments for moderation, including author’s comments on own post
- WordPress error when sending comment
- Why default comment fields don’t show up?