save custom field in form question
Cretae new custom field:
function custom_form_fields( $form ) {
// Upload field.
$form[’fields’][’budget’] = array(
‘label’ => __( ‘Budget’ ),
‘desc’ => __( ‘Tu presupuesto máximo..’ ),
‘subtype’ => ‘text’,
);
return $form;
}
add_filter( ‘ap_question_form_fields’, ‘custom_form_fields’ );
Save field:
function question_mysave( $post_id, $post ) {
global $validate;
if ( empty( $validate ) ) {
return;
}
$fields = $validate->get_sanitized_fields();
update_post_meta( $post_id, ‘budget’, $fields[’budget’] );
}
add_action( ‘ap_processed_new_question’, array( $this, ‘question_mysave’ ), 0, 2 );
add_action( ‘ap_processed_update_question’, array( $this, ‘question_mysave’ ), 0, 2 );
Don’t save the custom field. ¿why?
I have posted an answer here: https://anspress.io/questions/question/custom-field-not-saving/answer/29376/