Skip to content

Instantly share code, notes, and snippets.

@rahularyan
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahularyan/31883b4642f3d6e0b4a7 to your computer and use it in GitHub Desktop.
Save rahularyan/31883b4642f3d6e0b4a7 to your computer and use it in GitHub Desktop.
<?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;
}
@boyners
Copy link

boyners commented Mar 4, 2015

Where can we find this theme Qawork - Theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment