How to disable my website users to answer a closed discussion?

6.17K viewsCore
1

Hi,
Is there anyway that you will help me to disable my website users to answer a closed question as follows using anspress?
http://snowykyoko.com/caselaw/legal-answers-2/question/186/howdy-titus-here/

Mr. Raul told me that he can add this disable function to 1.4.3 version, could you do so asap please?
My customer prefers to use 1.4.3 for his website instead.

0

Sorry for late replay.

You can simply check if question has closed term using:

has_term( 'closed', 'question_label', get_question_id() )

Code for version 1.4.3:

Create a theme override by simply creating a new folder called anspress inside your active theme (not child theme). Now copy anspress/theme/default/answer-form.php to your newly created folder.

Now paste this:

<?php
    $question_id =get_question_id() ;
    $current_user = get_userdata( get_current_user_id() );
    $validate = ap_validate_form();
    if(!empty($validate['has_error'])){
    echo '<div class="alert alert-danger" data-dismiss="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>'. __('Problem submitting form, please recheck form', 'ap') .'</div>';
    }
?>
<?php 
// make sure closed label slug is "closed"
if( ap_question_have_labels() && has_term( 'closed', 'question_label', get_question_id() ) ): ?>
    <div id="answer-form-c">        
        <div class="ap-avatar">
            <?php echo get_avatar( $current_user->user_email, ap_opt('avatar_size_qquestion') ); ?>
        </div>
        <?php ap_answer_form($question_id); ?>
    </div>
<?php endif; ?>
You are viewing 1 out of 4 answers, click here to view all answers.