Question form custom fields not working
-
Hello, we have updated wordpress and anspress plugin, after that our custom code who adds and safes custom fields not working. Do not saves fields. Can you please check whats wrong?
Code:
/** * Adds a PDF field to AnsPress question form. * * @param array $form Form arguments. * @return void */ function my_custom_question_field( $form ) { // field. $form['fields']['date'] = array( 'label' => __( 'Jūs? ar ?mogaus, d?l kurio klausiate gimimo data ir laikas:' ), 'desc' => __( 'Tiksli data svarbi sudarant atsakym?.' ), 'subtype' => 'text', // Default type is set to input. 'attr' => array( 'placeholder' => 'Pvz.: 1991-08-25 14h 20min', ), 'sanitize' => 'text_field', // This sanitize will be applied by default for url field. 'validate' => 'required,max_string_length', // Require and check length of string. ); $form['fields']['city'] = array( 'label' => __( 'Gimimo miestas' ), 'desc' => __( '' ), 'subtype' => 'text', // Default type is set to input. 'attr' => array( 'placeholder' => 'Pvz.: Vilnius', ), 'sanitize' => 'text_field', // This sanitize will be applied by default for url field. 'validate' => 'required,max_string_length', // Require and check length of string. ); return $form; } add_filter( 'ap_question_form_fields', 'my_custom_question_field' ); /** * Save a upload field. */ function my_save_pdf_uploads($post_id,$post) { $form = anspress()->get_form( 'form_question' ); // Get all sanitized values. $values = $form->get_values(); if ( ! add_post_meta( $post_id, 'user_date', $values['date']['value'], true ) ) { update_post_meta( $post_id, 'user_date', $values['date']['value'] ); } if ( ! add_post_meta( $post_id, 'user_city', $values['city']['value'], true ) ) { update_post_meta( $post_id, 'user_city', $values['city']['value'] ); } } add_action( 'ap_processed_new_question', 'my_save_pdf_uploads' );
- The topic ‘Question form custom fields not working’ is closed to new replies.