custom field not saving

7.28K viewsIssues
1

I have register custom field for single-question.php template, “embed_video” and am trying to pass custom field from AnsPress ask form to this field.

function embed_video_field( $form ) {function embed_video_field( $form ) {  // Record Button field. $form['fields']['record'] = array(  'html' => '<div class=""><h3>A simple header</h3></div>',);
// Video field.  $form['fields']['video'] = array( 'type'          => 'input', 'subtype'       => 'text', 'label'         => __( 'Embed Video' ), 'attr'          => array( // custom HTML tag attributes. 'id'       => 'videourl', 'class'    => 'embed_video' ), 'sanitize'      => '', // Comma separated list of sanitization filters 'validate'      => '', // Comma separated list of validation methods);  return $form;}add_filter( 'ap_question_form_fields', 'embed_video_field' );

function hooks_save_meta_value($post_id,$post)function hooks_save_meta_value($post_id,$post){ $form = anspress()->get_form( 'form_question' ); // Get all sanitized values. $values = $form->get_values(); { if ( ! add_post_meta( $post_id, 'embed_video', $values['embed_video']['value'], true ) ) {   update_post_meta( $post_id, 'embed_video', $values['embed_video']['value'] ); } }add_action( 'ap_after_new_question', 'hooks_save_meta_value' );

 

Can anyone help me with this?

Changed status to publish

you can see this in working example here – user is able to record video and upload, we retrieve video URL after submission and populate custom “embed_video” field – but I still cannot save this value in the post meta.

http://fresh.richmondcounseling.org/community/questions/ask-a-question/

1

Hello Matt,

Here is an example I am doing to save a image field in a custom form. Also make sure to add valid mimes in field args. By default AnsPress allows only image mimes.

Loading Gist...
You are viewing 1 out of 2 answers, click here to view all answers.