Powered by MediaWiki
Personal tools

Require membership to post comments

From b2evolution manual

Jump to: navigation, search

This refers to b2evolution versions 0.9.x

The default configuration for b2evolution is to allow comments on posts, and to allow anyone to make a comment. When you make a post you have the option to either close or disable comments, but there is no option to say "only registered members can post a comment... unless you don't mind hacking a file ;)

NOTE: Hacks are not supported parts of b2evolution and may not work when you upgrade to newer versions. ALWAYS backup your files before you hack!

Each skin has a skinname, and each skins/skinname/ folder has a file called _feedback.php. If your skins/skinname/_feedback.php has this at the end of the file: <source lang="php"> /** * We now call the default feedback handler... * However you can replace this file with the full handler (in /blogs) and customize it! */ require get_path('skins').'/_feedback.php'; ?> </source> then you will need to edit skins/_feedback.php instead.

Open the appropriate _feedback.php file and look for this section: <source lang="php"> if( $disp_comment_form ) { // We want to display the comments form: if( $Item->can_comment() ) { // User can leave a comment ?>

<?php echo T_('Leave a comment') ?>:

</source> Now change it to this: <source lang="php"> if( $disp_comment_form && is_logged_in() ) { // We want to display the comments form to a registered member: if( $Item->can_comment() ) { // User can leave a comment ?>

<?php echo T_('Leave a comment') ?>:

</source>



1. In skins/skinname/_feedback.php and/or skins/_feedback.php mentioned above: <source lang="php"> /* Original code:

    }
    ?>

<?php } // if you delete this the sky will fall on your head ?>

  • /

// Begin Fix

    } else {
         ?>

You are not authorized to make a comment.

         <?php
         }
         ?>

<?php } // if you delete this the sky will fall on your head ?> // End Fix </source> 2. In htsrv/comment_post.php: <source lang="php"> /* Original Code: if( ! $commented_Item->can_comment( , , , ) ) {

    errors_add( T_('You cannot leave comments on this post!') );

}

  • /

// Begin Fix if( ! $commented_Item->can_comment( , , , ) ) {

    errors_add( T_('You cannot leave comments on this post!') );

} if( ! is_logged_in() ) {

    errors_add( T_('You are not authorized to leave comments on this post!') );

} // End Fix </source>