Last active
December 3, 2017 11:01
-
-
Save rahularyan/aac5c8f5a52318919f2989726e30d85a to your computer and use it in GitHub Desktop.
Add a PDF upload field in AnsPress questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a PDF field to AnsPress question form. | |
* | |
* @param array $form Form arguments. | |
* @return void | |
*/ | |
function my_custom_question_field( $form ) { | |
// Upload field. | |
$form['fields']['screenshot'] = array( | |
'fields' => array( | |
'pdf' => array( // This is a unique key for field. | |
'label' => __( 'PDF File' ), | |
'desc' => __( 'Allow single PDF file upload.' ), | |
'type' => 'upload', | |
'upload_options' => array( | |
'multiple' => false, // Only allow single image upload. | |
'allowed_mimes' => array( | |
'pdf' => 'application/pdf', // This will allow uploading of PDF file. | |
), | |
), | |
), | |
), | |
); | |
return $form; | |
} | |
add_filter( 'ap_question_form_fields', 'my_custom_question_field' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem : https://anspress.io/questions/question/how-to-insert-pdf-word-file-on-my-site-2/