Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    This will require you to do some PHP code.

    From the point of view of a form submission, you could check to see if the form submission has an file upload field set, and if not set it to some default image. But I do no t recommend this because you will be adding multiplies copies of the file to the database. This would be changing data before it is saved in the database.

    From the point of view of using a short code to output a form submission, you could check to see if the field is empty and if use use an alternate image. This requires you to create your own short code

    Thread Starter GiorgioC

    (@giorgioc)

    sorry michael i have just downloaded “Add actions and filters” plugin but, if I want use the first solution “From the point of view of a form submission, you could check to see if the form submission has an file upload field set, and if not set it to some default image. But I do no t recommend this because you will be adding multiplies copies of the file to the database. This would be changing data before it is saved in the database.” in what mode i can change the default avatar?
    I try with:

    function myFilter($formData) {
        if ($formData->uploaded_files['file-avatar'] != ""){
        	?
        }else{
        	?
        return $formData; // be sure to return it
    };
    
    add_filter('cfdb_form_data', 'myFilter');

    what’s the correct syntax to change default avatar?

    thanks

    Plugin Author Michael Simpson

    (@msimpson)

    I think you want something like this:

    function myFilter($formData) {
        if (!$formData->uploaded_files || !isset($formData->uploaded_files['file-avatar'])) {
            $formData->posted_data['file-avatar'] = 'name-of-default-file';
            if (!$formData->uploaded_files) {
                $formData->uploaded_files = array();
             }
            $formData->uploaded_files['file-avatar'] = '/path/to/default/file';
        }
        return $formData; // be sure to return it
    }
    add_filter('cfdb_form_data', 'myFilter');
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘cycle control IF’ is closed to new replies.