save custom field in form question

8.22K 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

Hello,

You are not saving it correctly. Please read our FAQ AnsPress form and validation API at the bottom there is an example of how to save form data.

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