• Resolved ramada78

    (@ramada78)


    this hook to make it rename files uploaded via form to the value of full name field which has “ID =17”. the hook works but it is giving the file the value of full name field from the previous entry instead of using the current.
    please help!

     function add_upload_prefilter() {
    $full_name_global = FrmProEntriesController::get_field_value_shortcode(array('field_id' => 17));
    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);

Viewing 1 replies (of 1 total)
  • Plugin Support Njones35

    (@njones35)

    Hi there,

    I’m afraid that we are only able to offer support for the Lite plugin via WordPress forums, and all queries about Pro functionality need to go via our helpdesk.

    Since file uploads are a Pro feature, could you please open a ticket here for assistance??https://formidableforms.com/new-topic/

    Best,
    Nathanael

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