save custom field in form question

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

Y don’t find an example in this page.

I only view this example
How to add a PDF upload field in AnsPress question form?
 

But don`t work.

 

I try:

 

function my_save_pdf_uploads( $post_id ) {
$field = $form->find(‘budget’);

update_post_meta( $post_id, ‘budget’, $field );
}
}
add_action( ‘ap_processed_new_question’, ‘my_save_pdf_uploads’ );

add_action( ‘ap_processed_update_question’, ‘my_save_pdf_uploads’ );

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