Custom code made the file upload image url dissapear
-
https://www.ads-software.com/support/topic/custom-user-meta-in-hidden-fields/
Previously I open a thread and the code is working very well , but somehow when I trying to add a fileupload, it cause the image url not showing in the submission, after remove the custom code, the file upload success and the image can send as attachment to my email
<?php add_action('forminator_custom_form_submit_before_set_fields', 'wpmudev_change_hidden_fields_data', 10, 3); function wpmudev_change_hidden_fields_data($entry, $module_id, $field_data_array) { $form_ids = array(62); //Please change the form ID if (!in_array($module_id, $form_ids)) { return; } if (!is_user_logged_in()) { return; } $user = wp_get_current_user(); $user_data = get_userdata($user->ID); foreach ($field_data_array as $key => $value) { // HERE YOU MODIFY YOUR HIDDEN FIELDS VALUES # set user bio if (strpos($value['value'], 'bank_account_number') !== false) { Forminator_CForm_Front_Action::$info['field_data_array'][$key]['value'] = $user_data->bank_account_number; } } } add_filter('forminator_prepared_data', 'wpmudev_update_hidden_field_val_copy', 10, 2); function wpmudev_update_hidden_field_val_copy($prepared_data, $module_object) { $form_ids = array(62); //Please change the form ID if (!in_array($module_object->id, $form_ids)) { return $prepared_data; } foreach ($prepared_data as $key => $value) { // repeat this block as many times as the number of hidden fields that you modified with code // note: here you don't use field values but actual hidden fields IDs // of hidden fields that you modified. if (strpos($key, 'hidden-1') !== false) { $prepared_data[$key] = sanitize_text_field($_POST[$key]); } } return $prepared_data; }
Meanwhile, i want to inspect what is the problem
You have a new website form submission:
{all_fields}{upload-1}
—
This message was sent from {site_url}.So i modified my email notification like this, and the result is
image url is sending to my gmail, but its show exactly same data with my hidden-field.
- The topic ‘Custom code made the file upload image url dissapear’ is closed to new replies.