Skip to:
Content
Pages
Categories
Search
Top
Bottom

plugin idea: “report this post”


  • _ck_
    Participant

    @_ck_

    I’m gonna need this one in a hurry so if there’s nothing similar in existance, looks like I have a weekend project.

    For now I’m going to keep it simple, add a text link somewhere in the template and that will popup a javascript query for a description why it should be moderated and then an email will be fired off to the admin. What I really want it to do is create a new post in the moderator forum so one of the mods will see it and take action, but that might have to wait until the next version.

    Am I the only one (other than the few documented examples) who’s using bbpress for something other than a micro-forum and needs these kinds of tools?

    ps. the examples page needs to be updated, over 200,000 registered members now

Viewing 11 replies - 1 through 11 (of 11 total)
  • 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


    _ck_
    Participant

    @_ck_

    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.


    _ck_
    Participant

    @_ck_

    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');

    ?>


    _ck_
    Participant

    @_ck_

    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?


    _ck_
    Participant

    @_ck_

    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).


    _ck_
    Participant

    @_ck_

    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.


    _ck_
    Participant

    @_ck_

    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.


    _ck_
    Participant

    @_ck_

    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)

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Skip to toolbar