Created
October 24, 2017 01:45
-
-
Save rahularyan/4c89eac75f51738f06c1fa88ac7dbd49 to your computer and use it in GitHub Desktop.
Add custom fields to AnsPress ask form.
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 | |
/** | |
* Add custom fields to AnsPress question form. | |
* | |
* This hook will add two new fields in ask form. | |
* | |
* @param array $form Form arguments. | |
* @return void | |
*/ | |
function my_custom_question_field( $form ) { | |
// Url field. | |
$form['fields']['website'] = array( | |
'label' => __( 'Your website' ), | |
'desc' => __( 'Enter link to your website.' ), | |
'subtype' => 'url', // Default type is set to input. | |
'attr' => array( | |
'placeholder' => 'https://mydomain.com/', | |
), | |
); | |
// Upload field. | |
$form['fields']['screenshot'] = array( | |
'label' => __( 'Screenshot' ), | |
'desc' => __( 'Upload screenshots of your website.' ), | |
'type' => 'upload', | |
'upload_args' => array( | |
'multiple' => false, // Only allow single image upload. | |
), | |
); | |
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
Hello, this works perfectly but contents of the custom field are not getting saved in the question upon submitting