Last active
August 29, 2015 14:02
-
-
Save rahularyan/31883b4642f3d6e0b4a7 to your computer and use it in GitHub Desktop.
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 | |
// register custom fields | |
qw_add_filter('custom_question_fields', 'qw_custom_question_field'); | |
function qw_custom_question_field($form){ | |
$form['qw_custom'] = array( | |
'label' => 'Custom Field', | |
'tags' => 'name="qw_custom"', | |
'type' => 'text', | |
'value' => '' | |
); | |
$form['qw_coding'] = array( | |
'label' => 'Your coding language', | |
'tags' => 'name="qw_coding"', | |
'type' => 'select', | |
'options' => array('PHP' => 'PHP', 'JavaScript' => 'JavaScript', 'HTML' => 'HTML', 'Visual Basic' => 'Visual Basic') | |
); | |
return $form; | |
} | |
// process custom fields and save in DB | |
qw_add_filter('custom_save_question_fields', 'qw_custom_save_question_field'); | |
function qw_custom_save_question_field($fields){ | |
$fields['qw_custom'] = qa_post_text('qw_custom'); | |
$fields['qw_coding'] = qa_post_text('qw_coding'); | |
return $fields; | |
} | |
//Custom field output | |
qw_add_action('show_custom_question_fields', 'qw_show_custom_question_field'); | |
function qw_show_custom_question_field($fields, $post){ | |
$output = ''; | |
if(isset($fields['qw_coding'])) | |
$output .= '<p>I love '.$fields['qw_coding'].'</p>'; | |
if(isset($fields['qw_custom'])) | |
$output .= '<p>My reason: '.$fields['qw_custom'].'</p>'; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where can we find this theme Qawork - Theme