Comment gets stuck at https://randomwpsite.com/wp-comments-post.php
-
It is not advised to edit core WP files such as comment.php.
That said, this sounds like a potential plugin or theme conflict. I would suggest trying to debug using the Health Check plugin found here https://ww.wp.xz.cn/plugins/health-check/
Hope this helps. Once you find a permanent solution please tag the thread as resolved.
The problem is still there in troubleshooter running mode.
Actually, when any user try to comment on any post, it gets stuck at https:///wp-comments-post.php with a post data. Usually, it should be redirected back to the post. But it doesn’t.
As I mentioned abovedo_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );inwp_new_comment( $commentdata, $avoid_die = false )function from file-
site_directory/wp-includes/comment.php
is not working.
-
This reply was modified 7 years, 1 month ago by
viratraaz.
Your site url is not being read correctly by the code. Are you setting the site url and/or wp url in code or in the General Settings of wp-admin?
WordPress Address (URL) : https://questuff.com Site Address (URL) : https://questuff.comI have no knowledge of wordpress core files. I just proceeded from file site_directory/wp-comments-post.php to check what is causing problem.
-
This reply was modified 7 years, 1 month ago by
viratraaz.
Where are the site url and wp url set?
when you look in your admin dashboard under Settings → General are you able to edit them there or are the fields grayed out?I am able to edit both the field in General Settings from frontend admin panel
okay. so the problem is not what I was thinking it was. I am at a loss but I will draw the attention of others to this thread. someone will hopefully be able to provide you with a solution soon. Sorry I could not be of more help.
better, if i know, what is the use of
do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );in
wp_new_comment( $commentdata, $avoid_die = false )function from file site_directory/wp-includes/comment.php , i could write my own code or find any alternative solution.No, this code is not the problem. The problem is because your site url is not being recognized by the WP core code…..
this became clear to me when you saidActually, when any user try to comment on any post, it gets stuck at https:///wp-comments-post.php with a post data.
about an hour ago.
Actually, where is that code? Have you tried deleting it ?
Also, when you ran the Health check plugin are you sure you were running the troubleshooter? It does not run it by default. You have to be sure you are running the site using a default WP theme (it will only change the theme for the logged in user) Installing and activating the plugin does not activate the troubleshooter you have to choose to use the troubleshooting mode which will deactivate all plugins and the active theme (unless the active theme is a default theme).
Open
site_directory/wp-includes/comment.phpSearch for
wp_new_comment( $commentdata, $avoid_die = false ){....}read this function
see the last second line, it is
do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );If I remove/comment this line, everything works great.
Secondly:
I followed your suggestion
I installed plugin from https://ww.wp.xz.cn/plugins/health-check/
then I activated the plugin.
after that I started troubleshooting, I got a message https://ibb.co/hDJsgg9
then I test the bug again. The bug didn’t get resolved.I think your wp install may have been compromised. because this is not normal for it to return that error and you are saying that the error occurs even when you are in debug mode using health check. So please check your site using a security plugin such as Sucuri or WordFence to check and be sure your site has not been compromised.
@viratraaz There is nothing wrong with the do_action line. This is a standard call to invoke the WordPress Action Hook.
If you have problems at this point in the code, then you have a plugin or some other code that is hooked to the comment_post action which is causing the problem. This could be an anti-spam plugin such as akismet, or anything else that modifies the way your site handles comments.
Instead of messing with the core code, try disabling your plugins to find the actual source of the problem. Re-enable them one at a time until the problem recurs, and then you will know where the issue really is.
@viratraaz
What you see when you post comment? Blank screen or any error message?
Please enable debug. https://codex.ww.wp.xz.cn/Debugging_in_WordPress
Deactivate all plugins and change theme to one of default theme (tweenty*)
Then post a comment and check server error log if you see any error regarding this.if you do not see any error do following.
in comment.php just beforedo_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );add following linesglobal $wp_filter; if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { var_dump( $wp_filter['comment_post'] ); die; }Then post a comment and give here what you see in browser
-
This reply was modified 7 years, 1 month ago by
Shamim Hasan.
-
This reply was modified 7 years, 1 month ago by
The topic ‘Comment gets stuck at https://randomwpsite.com/wp-comments-post.php’ is closed to new replies.
(@viratraaz)
7 years, 1 month ago
After looking everything, I found that:
there is a function called
wp_new_comment( $commentdata, $avoid_die = false )
in site_directory/wp-includes/comment.php where
do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );
is not working.
I want to know where this function is defined and where the file is included?
According to my analysis ‘do_action’ function is being called from site_directory/wp-includes/plugin.php but I don’t see enough arguments in the defined function.
Please help.
{temporary solution: comment line
do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );
which is in
wp_new_comment( $commentdata, $avoid_die = false )
function from file site_directory/wp-includes/comment.php}