QuestionsCategory: General Questionsquestion form design
mhmmdcngms2
asked 3 weeks ago
I can't edit the ask a question page. How can I add my phone number or other information to the form?
3 Answers
tech Staff
answered 3 weeks ago
Could you let me know details about the question? If you want to add more information to the form, you can open the question-submit-form.php to custom this template. 
mhmmdcngms2
answered 3 weeks ago
Thank you for your return.

Phone Number?
City?

What should the "question-submit-form.php" form be like? And Will the form not change when the extension is updated? 



   
techStaff
replied 2 weeks ago

We will customize the template and will provide a example to you as soon as possible.

tech Staff
answered 1 week ago
Hi, 

1/ To add custom fields to the submit question form, you can add the following code to the submit-question-form.php file line 79:
<p>
<!-- // add new fields -->
<label for="question-phone"><?php _e( 'phone', 'emqa' ) ?></label>
<?php $phone = isset( $_POST['question-phone'] ) ? $_POST['question-phone'] : ''; ?>
<input type="text" class="emqa-question-phones" name="question-phone" value="<?php echo $phone ?>" >
</p>
<p>
<label for="question-city"><?php _e( 'city', 'emqa' ) ?></label>
<?php $city = isset( $_POST['question-city'] ) ? $_POST['question-city'] : ''; ?>
<input type="text" class="emqa-question-city" name="question-city" value="<?php echo $city ?>" >
</p>

2/ Add this code to the inc/Handle.php file (line 500):
$phone= isset( $_POST['question-phone'] ) ? $_POST['question-phone'] : '';
$city = isset( $_POST['question-address'] ) ? $_POST['question-address'] : '';

And under line 578: 
update_post_meta( $new_question, '_emqa_question_phone', $phone );
update_post_meta( $new_question, '_emqa_question_city', $city );



3/ To show the data in the single question, you can open the content-single-question.php file and add the following code to the position that you wish: 
<?php
$phone = get_post_meta( get_the_ID(), '_emqa_question_phone', true );
echo 'Job: '. $phone;
?>
<?php
$city = get_post_meta( get_the_ID(), '_emqa_question_city', true );
echo 'City: '. $city;
?>

Please login or Register to submit your answer