custom field (image) not saved
Author | Posts |
---|---|
September 5, 2013 at 10:22 pm 7837 | |
lwrkrol | I have a custom post type with an imagefield. I use the correct fieldname in the form, but it's not saving to the meta field of this CPT (which is saved in an array) I use this code in 'specialImage' => isset( $_POST['specialImage'] ) ? $_POST['specialImage'] : '', in the wpuf-functions.php Other custom fields are saved ok, should I use other code for an image ? |
September 6, 2013 at 1:18 am 7841 | |
lwrkrol | I changed the field type to text and then it’s saved correctly so it must be related to the image field. |
September 8, 2013 at 11:58 am 7912 | |
lwrkrol | But that is not what I want. I want to select a file in my form and the path to the uploaded file should be stored in the meta field. So how to do this ? |
September 8, 2013 at 12:21 pm 7916 | |
Tareq Hasan | Please take a look here. |
September 8, 2013 at 1:14 pm 7918 | |
lwrkrol | Hi, I think I can get that working but the thing is that the other fields are stored using an array. I thought I could solve it like this, but it creates another metafield instead of adding it to the array. $ait_dir_item = array ( add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_ait_integration’ ); // save specialImage if ( $attach_id ) { add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_copy_att_url’ ); |
September 8, 2013 at 1:22 pm 7919 | |
Tareq Hasan | FYI, the files could be accessed like this: |
September 8, 2013 at 2:18 pm 7922 | |
lwrkrol | I’m not sure how to use that, when I change to ‘specialImage’ => isset( $_POST[‘wpuf_files’][‘specialImage’] ) ? $_POST[‘wpuf_files’][‘specialImage’] : ”, I get the word: Array in that field. |
September 8, 2013 at 3:23 pm 7926 | |
Tareq Hasan | I think this is what you are looking for: |
September 8, 2013 at 3:29 pm 7928 | |
lwrkrol | That worked, thank you very much Tareq! |
September 9, 2013 at 12:42 pm 7945 | |
lwrkrol | Weel it works when there is only 1 statement that does this. I wanted to add some more but then it’s not working anymore: What am I doing wrong here ? The fields gallery1 and gallery2 stay empty |