Custom file name in cforms upload

I really like the cforms plugin for wordpress. It’s very powerful, yet easy to use.
But today I ran into a dead-end.

Basically I need a form to let users submit their first- and last name, then upload two files, which I need to rename to “A_Firstname.Lastname.ext” and “B_Firstname.Lastname.ext“.

Read More

By default cforms just leaves the file name as it was by the uploader.
If anyone is familiar with the cforms plugin then any guidelines would be much appreciated!

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. You can change the filename by creating a my_cforms_logic function in my-functions.php (my_cforms_logic is called from line 270 of lib_validate.php if you want to understand why it works).

    There is an example in the sample my-functions.php but even simpler example of adding test_ to the beginning of the given filename would look like this:

    function my_cforms_logic($cformsdata,$oldvalue,$setting) {
    
    if ( $setting == "filename" ){
        return 'test_' . $oldvalue;
    }
    
    return $oldvalue;
    }
    

    So if you can figure how to access the values of the first and last name (I suspect something along the lines of $cformsdata[‘data’][‘Firstname’] will work) then you should be in business.

    Phil