afsaneh
asked 6 years ago

Hi, I purchased DW Question & Answer Pro plugin.
I want to add 2 required text fields before title field and display them on single question page.
Can you help me to add php code (not CSS) ?
Thanks a lot
 
 

4 Answers
DominicStaff
answered 6 years ago

I sent and notified to our technical team about your requestions, we will check and help you resolve it. 

afsaneh
replied 6 years ago

Thank you, I wait the technical response…

Allen
answered 6 years ago

Hi, so sorry for my late reply to you, you can follow this instruction

  1. To add new fields,, you need to change the code in file : dw-question-answer-pro/templates/question-submit-form.php  like in this link to add 2 custom field of job and address, and remember the name of the input text that you have added.
    you can also download the full code here :
    http://pastebin.com/QnGUAhyG

    *Note, to note make the customize change due to update, you can read this guide to overwrite the template file of DW Q&A in your theme : https://www.designwall.com/guide/dw-question-answer-plugin/style-integration/

  2. After that you need to open file  dw-question-answer-pro/inc/handle.php in this file, you need to search for the function : submit_question(), that’s the function in charge of the process of adding questio, then you need to modify it to save the job, and the address data. In here, to save them you need to use function : update_post_meta()  or add_post_meta() to save the data relate to the question. And remember the meta_key to show it on the single page
    you can also download the customize file here : http://pastebin.com/MqMi1GMN
  3. After saved it, the last thing to do is show it on the single question page or any where you want by using the function : get_post_meta(). Like in this example i’ll show it on the question single page by add code in file : dw-question-answer-pro/templates/content-single-question.php
    http://pastebin.com/p6jGJ1iu

If you have a hard time to implement it, you can also provide me your site and an admin account to login via private question i’ll help you make it. And it’ll be much safer and faster with the FTP info

afsaneh
replied 6 years ago

Thank you, new fields are displayed in question template.

afsaneh
answered 6 years ago

Now I want display two fields in the anwer template too !
Thank for your support.
 

Allen
replied 6 years ago

Hi, so sorry for my late reply, to you, to add the 2 boxes in the Answer submit form, you can do the same as the instruction above.
*For adding 2 new text boxes in the answer submit form you need to add to file : dw-question-answer-pro/templates/answer-submit-form.php
*After that, need to add a save function in file : dw-question-answer-pro/inc/handle.php, function insert_answer()
*And the last thing is to show it by add code to file :dw-quesstion-answer-pro/templates/content-single-answer.php

afsaneh
answered 6 years ago

Sorry but I’m not a php developper, fields do not work in the answer form.
__________
Here details of my works, I added same code to add fields in question form :
 
////////// content-single-answer.php – line 15 ////////////////////

<div class="dwpa-job">
<?php
$job = get_post_meta(get_the_ID(), '_dwqa_question_job', true);
echo 'job : ' . $job;
?>
</di>
<div class="dwpa-address">
<?php
$address = get_post_meta(get_the_ID(), '_dwqa_question_address', true);
echo 'Address : ' . $address;
?>
</div>

 
////////// answer-submit-form.php – line 13 ////////////////////

<div class="label-name-job">    
        <p>
            <label for="question-job"><?php _e( 'Your job', 'dwqa' ) ?></label>
            <?php $job = isset( $_POST['question-job'] ) ? $_POST['question-job'] : ''; ?>
            <input type="text" class="dwqa-question-jobs" name="question-job" value="<?php echo $job ?>" >
        </p>
        <p>
            <label for="question-address"><?php _e( 'Your address', 'dwqa' ) ?></label>
            <?php $address = isset( $_POST['question-address'] ) ? $_POST['question-address'] : ''; ?>
            <input type="text" class="dwqa-question-address" name="question-address" value="<?php echo $address ?>" >
        </p>    
    </div>

 
////////// handel.php ////////////////////
I don’t know how to add  function submit_answer(). Please, can you give me the code ?
 
__________
Thank you for your support.      

afsaneh
replied 6 years ago

If you want php access, it’s possible. Thank you.

Allen
replied 6 years ago

Yes, i would like to have access to your dashboard

Powered by DW Question & Answer Pro