save custom field in form question

9.02K viewsIssuesbug
0

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?

Answered question
0

I have posted an answer here: https://anspress.io/questions/question/custom-field-not-saving/answer/29376/

Answered question
You are viewing 1 out of 3 answers, click here to view all answers.