Pierre Mc Mahon
asked 4 years ago

Hello,

Your Q/A plugin is really great. Good job.

I had 2 questions :

  • Can we setup email field (when a question is submited) as "required" field ?
  • Is it possible to capture the email field ?

Thanks you very much in advance.

Pierre

1 Answers
DominicStaff
answered 4 years ago

I know what you want. Currently, our theme does not to make all fields of Submit question page as you mentioned here. However, you can copy the following code and replace all codes line in the question-submit-form.php file. I have made some change to code to Required for some field (email, name, tag). Also, we are planning to update this issue in the next version. We will release it as soon as possible.

<?php
/**
 * The template for displaying single answers
 *
 * @package DW Question & Answer
 * @since DW Question & Answer 1.4.2
 */
?>

<?php do_action( 'dwqa_before_question_submit_form' ); ?>
<form method="post" class="dwqa-content-edit-form">
    <p class="dwqa-search">
        <label for="question_title"><?php _e( 'Title', 'dwqa' ) ?></label>
        <?php $title = isset( $_POST['question-title'] ) ? $_POST['question-title'] : ''; ?>
        <input type="text" data-nonce="<?php echo wp_create_nonce( '_dwqa_filter_nonce' ) ?>" id="question-title" name="question-title" value="<?php echo $title ?>" tabindex="1">

    <?php $content = isset( $_POST['question-content'] ) ? $_POST['question-content'] : ''; ?>

<?php dwqa_init_tinymce_editor( array( 'content' => $content, 'textarea_name' => 'question-content', 'id' => 'question-content' ) ) ?>
    <?php global $dwqa_general_settings; ?>
    <?php if ( isset( $dwqa_general_settings['enable-private-question'] ) && $dwqa_general_settings['enable-private-question'] ) : ?>

        <label for="question-status"><?php _e( 'Status', 'dwqa' ) ?></label>
        <select class="dwqa-select" id="question-status" name="question-status">
            <optgroup label="<?php _e( 'Who can see this?', 'dwqa' ) ?>">
                <option value="publish"><?php _e( 'Public', 'dwqa' ) ?></option>
                <option value="private"><?php _e( 'Only Me &amp; Admin', 'dwqa' ) ?></option>
            </optgroup>
        </select>

    <?php endif; ?>

        <label for="question-category"><?php _e( 'Category', 'dwqa' ) ?></label>
        <?php
            wp_dropdown_categories( array(
                'name'          => 'question-category',
                'id'            => 'question-category',
                'taxonomy'      => 'dwqa-question_category',
                'show_option_none' => __( 'Select question category', 'dwqa' ),
                'hide_empty'    => 0,
                'quicktags'     => array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ),
                'selected'      => isset( $_POST['question-category'] ) ? $_POST['question-category'] : false,
            ) );
        ?>

        <label for="question-tag"><?php _e( 'Tag', 'dwqa' ) ?></label>
        <?php $tags = isset( $_POST['question-tag'] ) ? $_POST['question-tag'] : ''; ?>
        <input type="text" class="" name="question-tag" value="<?php echo $tags ?>" aria-required="true" required="required">

    <?php if ( dwqa_current_user_can( 'post_question' ) && !is_user_logged_in() ) : ?>

        <label for="_dwqa_anonymous_email"><?php _e( 'Your Email', 'dwqa' ) ?></label>
        <?php $email = isset( $_POST['_dwqa_anonymous_email'] ) ? $_POST['_dwqa_anonymous_email'] : ''; ?>
        <input type="email" class="" name="_dwqa_anonymous_email" value="<?php echo $email ?>" aria-required="true" required="required">

        <label for="_dwqa_anonymous_name"><?php _e( 'Your Name', 'dwqa' ) ?></label>
        <?php $name = isset( $_POST['_dwqa_anonymous_name'] ) ? $_POST['_dwqa_anonymous_name'] : ''; ?>
        <input type="text" class="" name="_dwqa_anonymous_name" value="<?php echo $name ?>" aria-required="true" required="required">

    <?php endif; ?>
    <?php wp_nonce_field( '_dwqa_submit_question' ) ?>
    <?php dwqa_load_template( 'captcha', 'form' ); ?>
    <input type="submit" name="dwqa-question-submit" value="<?php _e( 'Submit', 'dwqa' ) ?>" >
</form>
<?php do_action( 'dwqa_after_question_submit_form' ); ?>

Hope this helps!

Powered by DW Question & Answer Pro