It might not be what you are working on, but all the major forums that I use have users tag threads as “modlook” to do this very thing and that is what I want users to do on this forum.
Trent
Interesting, but I want something more direct.
Actually, I have a working prototype now and will post a very early beta in an hour or so.
And a report post plugin is born – tested working!
Needs a few features but gets the job done for now:
<?php
/*
Plugin Name: report post
Description: allows members to report a post to admin/moderators
Plugin URI: http://CKon.wordpress.com
Author: _ck_
Author URI: http://CKon.wordpress.com
Version: 0.1
*/
/*
instructions: install, activate and put <? report_post_link(); ?> in your post.php template where you want the link to be seen
optional in stylesheet: a.report_post {color:red;}
todo:
1. don't let them report more than once on a post - or more than too many times per minute/hour
2. auto-delete post if more than x reports from different members
3. auto-post report into a specified moderator's forum #
4. maybe ajax xmlhttp call instead of real form post so there's no page movement
5. it's technically possible to alert a browing mod with a popup directing to the reported post, no email needed
*/
function report_post_link($post_id=0) {
if (bb_current_user_can('participate') ) :
$post_id= get_post_id( $post_id );
if (get_post_author_id($post_id) != bb_get_current_user_info( 'id' )) {
echo '<a class=report_post title="report post to moderator" href="#post-'.$post_id.'" onClick="report_post('.$post_id.');return false;">Report</a>';
}
endif;
}
function report_post_form() {
if (bb_current_user_can('participate')) :
if (isset($_POST['report_post_id']) && isset($_POST['report_post_reason'])) {
echo '<scr'.'ipt type="text/javascript">alert("Thank you for the report. A moderator has been notified.");</scr'.'ipt>';
$post_id=intval($_POST['report_post_id']);
// todo: custom response if invalid id, problem sending email - maybe flush output buffer so member gets alert faster
$to = bb_get_option('admin_email');
$subject = " reported post by member for moderation";
$headers = "From: ".bb_get_option('admin_email');
$message ="report by: ".bb_get_current_user_info( 'name' )." (".bb_get_current_user_info( 'id' ).") email: ".bb_get_current_user_info( 'email' )."rnrn";
$message.="report: ".wordwrap(strip_tags(substr($_POST['report_post_reason'],0,255)),70)."rnrn".get_post_link($post_id)."rn";
$message.="post by: ". get_post_author($post_id)."rn"; // add "member since", total posts, blah blah
$message.="rnrnReport Trace:rn";
$message.="IP: ".$_SERVER['REMOTE_ADDR']."rn";
$message.="Host: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."rn"; // useful but can add a few seconds
$message.="Agent: ".$_SERVER['HTTP_USER_AGENT']."rn";
$message.="Refer: ". $_REQUEST['refer']."rn";
$message.="URL: http://".$_SERVER['HTTP_HOST'].$GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"]."rn";
mail( $to, $subject, $message,$headers);
}
echo '<form method="POST" name="report_post_form" id="report_post_form" style="display:none;visibility:hidden"><input type=hidden name="report_post_id"><input type=hidden name="report_post_reason"></form>';
echo '<scr'.'ipt type="text/javascript">
function report_post(post_id) {
var report_post_reason = prompt("Please enter a short but descriptive reason why a moderator needs to review this post:", "");
if (report_post_reason && report_post_reason.length>9) {
document.report_post_form.report_post_id.value=post_id;
document.report_post_form.action="#post-"+post_id;
document.report_post_form.report_post_reason.value=report_post_reason;
document.report_post_form.submit();
} else {alert("report cancelled, incomplete description"); }
}
</scr'.'ipt>';
endif;
}
add_action('bb_foot', 'report_post_form');
?>
Coming soon:
don't allow reports on moderators
don't allow reports from members less than x days old
security check if user is in the right topic for the post being reported
hum i upload it and active it and insert <? report_post_link(); ?> in post but nothing apeaer .8.2.1
what is the problem?
Sorry I didn’t see your bug report until just now.
I am working on this tonight and will have a working version posted soon (including translation hooks for you).
I’ve tested this now up to the bbpress trunk and it seems to work fine.
Try the latest:
https://bbpress.org/plugins/download/report-post.zip
Make sure you are editing post.php in your bb-templates or my-templates?
Unfortunately there is no hook for me to place it automatically in post.php on that info line. Wish there was.
It’s working for me…
I think the problem mazdakam is having is that moderators won’t see the link… you have to login as a regular user.
Which is the correct behavior, of course.
Moderators do see the link, you just don’t see it on your own posts, there’s no point in reporting yourself, LOL!
Ohhhhh
My test site has nothing but posts from me, no wonder I didn’t see it
And to answer your question at the very top of this thread, I’m trying to use bbPress for a serious forum… I just opened my forum a little over a week ago. Not as much traffic as I’d like, of course, but decent.
Yeah you should always create a non-moderator test user to see how other things interact compared to mod/admin. It’s important to see what’s hidden from regular members and sometimes admin can do things we take for granted that regular members cannot (ie. like my admin-can-post-anything plugin)