So, I went into the database and ran the select query that is in the wp_comments_posts.php script to return the status of the actual post that being commented on.
Apparently since it is setting the comment_post_id to zero some how (even though it’s 2 in the database) it is returning the null value for the post_status.
For example I had the comment_post_id and status variable print and ran it, which returned a value of 0 for the comment_post_id and null for the status.
I went to the php script file and copied and pasted the SQL that it was using to retrieve the status of the post and opened up MySQL query browser and connected to the database using my user. I ran:
SELECT * FROM wp_posts;
I was looking for the post that I was trying to comment on and found that the ID that it was using in the SQL query in the wp_comments_posts.php file was looking for the post with the ID of 0.
For example:
SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = ‘$comment_post_ID’
So I am wondering if I just create a post with the ID of 0 will that fix my problem?
But yeah the main problem with the posting of comments is that it isn’t retrieving the value of the hidden input in the form with the name comment_post_id and the value that is equal to the id of the post. Instead it is setting it to zero when running this code:
$comment_post_ID = (int) $_POST[‘comment_post_ID’];
(@wilsonke)
19 years, 2 months ago
Apparently this file is being called after clicking the Submit Comment button. I edited the PHP file wp-comments-post.php and printed out these variables:
print ($comment_post_ID);
print ($status);
and then when it decides what to do based on the status of the post_id i did another print because i wasn’t getting a status
if ( empty($status->comment_status) ) {
do_action(‘comment_id_not_found’, $comment_post_ID);
print(‘comment_id_not_found’);
exit;
} elseif ( ‘closed’ == $status->comment_status ) {
do_action(‘comment_closed’, $comment_post_ID);
die( __(‘Sorry, comments are closed for this item.’) );
} elseif ( ‘draft’ == $status->post_status ) {
do_action(‘comment_on_draft’, $comment_post_ID);
exit;
}
how the heck do I fix the fact that i am getting no status and therefor it is forcing me to exit? which tells me that there is something that is failing before that, but what? this is the code for the form that is being posted for the comment for the comment post ID:
<input type=”hidden” name=”comment_post_ID” value=”2″ />
I’m getting a comment_post_ID of 0 and no status value at all when the form posts and runs wp-comments-posts.php? Can someone help? It would be greatly appreciated. I would like to enable comments on my blog. I’m running MySQL 5.0.27 and PHP 5.2 on a MS 2000 Advanced Server with IIS 5.1. Thanks.`