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

6.28K 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

Hello,

Could you help me disable my website users to answer at a closed discussion ASAP please?

I erased the all of the code of duplicated anspress/theme/default/answer-form.php in my new folder called anspress. Then I copied and pasted the code that you gave me in my new anspress folder. Besides my new folder, everything is as same as original.

Following is the code that you gave me and I copied and pasted.

<?php
$question_id =get_question_id() ;
$current_user = get_userdata( get_current_user_id() );
$validate = ap_validate_form();
if(!empty($validate['has_error'])){
echo '×Close’. __(‘Problem submitting form, please recheck form’, ‘ap’) .”;
}
?>

user_email, ap_opt(‘avatar_size_qquestion’) ); ?>

Get the latest commit, it solve the issue

0

wait, how to close a discussion?

You can do it from admin, edit question and set status to closed. But I am working right now so that you can close it directly from post setting.. (same location where you is edit and flag button are)

0

Hi

I followed your reply, but it did not work. Is there anyway that you will help me out solving this asap please.

https://wordpress.org/support/topic/disable-anspress-users-to-answer-a-closed-conversation-in-my-website?replies=1#post-6868491

Please show me what you have added in answer-form.php

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; ?>