• Resolved ramada78

    (@ramada78)


    I tried adding this hook to make the form rename uploaded files to the value of Full Name field in my form, and it is working but unfortunately it is taking the value of Full Name field from the previous form entry instead of the current value, how to solve that?

        function add_upload_prefilter() {
    $full_name_global = FrmProEntriesController::get_field_value_shortcode(array('field_id' => 17, 'user_id' => 'current'));
    
    add_filter('wp_handle_upload_prefilter', function($file) use ($full_name_global) {
    static $counter = 1;
    $original_name = $file['name'];
        $extension = pathinfo($original_name, PATHINFO_EXTENSION);
        $formatted_counter = str_pad($counter, 2, '0', STR_PAD_LEFT);
        $new_filename = $full_name_global . '_' . $formatted_counter . '.' . $extension;
        $file['name'] = $new_filename;
        $counter++;
        return $file;
    });
    }
    add_action('wp_ajax_nopriv_frm_submit_dropzone', 'add_upload_prefilter', 1);
    add_action('wp_ajax_frm_submit_dropzone', 'add_upload_prefilter', 1);

    • This topic was modified 11 months, 3 weeks ago by ramada78.
Viewing 1 replies (of 1 total)
  • Plugin Support Njones35

    (@njones35)

    It looks like this is a duplicate question and your other topic has already received a response, so I’ll mark this resolved.

Viewing 1 replies (of 1 total)
  • The topic ‘Rename form uploaded files’ is closed to new replies.