First, you have to "alter" your database to add "private" field. Login to your CPanel and then phpMyAdmin; click on
"b2comments" table and then go into the SQL section. In this section, run the following:
ALTER TABLE b2comments ADD comment_private INT(1) DEFAULT 0 NOT NULL;
---
In b2functions.php file under get_commentdata functions, add the following:
$myrow['comment_private']=$rowc->comment_private;
---
In b2template.functions.php file under generic_ctp_number function, locate:
global $postdata, $tablecomments, $querycount, $cache_ctp_number, $use_cache;
Change it to:
global $postdata, $tablecomments, $querycount, $cache_ctp_number, $use_cache, $pagenow;
Then locate:
$query = "SELECT * FROM $tablecomments WHERE comment_post_ID = $post_id";
Replace it with:
if ($pagenow != 'b2edit.php') {
$query = "SELECT * FROM $tablecomments WHERE comment_post_ID = $post_id AND comment_private = 0";
}
else {
$query = "SELECT * FROM $tablecomments WHERE comment_post_ID = $post_id";
}
---
In b2comments.post.php file, add the following:
$comment_private = $HTTP_POST_VARS["comment_private"];
After:
$comment_post_ID = $HTTP_POST_VARS["comment_post_ID"];
Then locate the SQL insert statement:
$query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0')";
Change it to:
$query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0','$comment_private')";
Now. just before the following line:
$notify_message = "New comment on your post #$comment_post_ID.\r\n\r\n";
Place the following:
if ($comment_private) {
$comment_private_yesno = 'yes';
}
else {
$comment_private_yesno = 'no';
}
And right after the following line:
$notify_message .= "url : $comment_author_url\r\n";
Place the following line:
$notify_message .= "private : $comment_private_yesno\r\n";
---
If you have installed my "comment subscription/notification" hack, that SQL syntax should be:
$query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0','$notify', '$comment_private')";
Then locate:
$nquery = " SELECT DISTINCT comment_author_email, comment_notify " .
" FROM $tableposts LEFT JOIN $tablecomments ON ID = comment_post_id " .
" WHERE ID = '$comment_post_ID' AND comment_notify = 1 " .
" ORDER BY comment_ID DESC";
And modify it to:
$nquery = " SELECT DISTINCT comment_author_email, comment_notify " .
" FROM $tableposts LEFT JOIN $tablecomments ON ID = comment_post_id " .
" WHERE ID = '$comment_post_ID' AND comment_notify = 1 AND comment_private = 0" .
" ORDER BY comment_ID DESC";
---
This is optional. If you want to "tag" your private comments in the b2edit page, open up "b2edit.showposts.php" file
and locate:
And place the following line right after:
-----
For those of you with the e-mail notification turned off, do the following in b2comments.php and b2commentspopup.php
files...
Place the following within the while loop for comments:
...comment code goes here...
';
echo 'here to view it.';
}
?>
You have to place your own comment codes in between "" and "". This block of codes
will display a message and a direct link to that comment in your b2edit page.
For those with the e-mail notification turned on...
In b2comments.php and b2commentspopup.php files, locate the following SQL select syntax:
$queryc = "SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date";
This SQL syntax may not be exactly like above depending which hack you installed.
Then replace it with or modify it to:
$queryc = "SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_private = 0 ORDER BY comment_date";
-----
Within the commenting form, include the following input tag where you want the checkbox to appear:
Private comment
---
If you have my "latest comments" hack installed, locate the following line in the latestcomments function:
" AND comment_content != '' " .
Then replace it with or modify it to:
" AND comment_content != '' AND comment_private = 0 " .
---
If you have my "notify me" hack installed, locate the following line in b2comments.post.php file:
if ($wxcvbn_c > 0) {
Then change it to:
if ($wxcvbn_c > 0 && $comment_private == 0) {
---
You are done with the implementation. With this hack installed, your visitors will be able to send you private comments
without having them appear publicly on your site. You can still edit the contents of these comments from your b2edit
page, but I didn't make it possible for you to change their status of privacy.