• Resolved hydevelop1994

    (@hydevelop1994)


    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.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @hydevelop1994,

    Since you have already created a new thread to follow up regarding the image URL issue, I’ll go ahead and mark the old thread as resolved for now.

    https://www.ads-software.com/support/topic/custom-user-meta-in-hidden-fields/

    Regarding the issue, could you please also share the form export, so that we could have a better idea to check what could be suggested further?

    Please check the following doc on how to export a form:
    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export

    If you are concerned about any sensitive information in the form, then you can duplicate your form, remove any sensitive information, and then export it.

    You can share the export file via Google Drive, Dropbox or any cloud services in the next reply.

    Looking forward to your response.

    Best Regards,

    Nithin

    Thread Starter hydevelop1994

    (@hydevelop1994)

    {“type”:”form”,”data”:{“fields”:[{“id”:”upload-1″,”element_id”:”upload-1″,”form_id”:”wrapper-9142-3674″,”parent_group”:””,”type”:”upload”,”options”:[],”cols”:”12″,”conditions”:[],”wrapper_id”:”wrapper-9142-3674″,”field_label”:”Upload file”,”filetypes”:[“jpg|jpeg|jpe”,”png”,”webp”,”css”,”htm|html”,”dfxp”,”js”],”file-type”:”single”,”file-limit”:”unlimited”,”upload-limit”:”5″,”filesize”:”MB”,”custom-files”:”1″,”use_library”:”true”,”required”:”1″},{“id”:”hidden-1″,”element_id”:”hidden-1″,”form_id”:”wrapper-8983-4113″,”parent_group”:””,”type”:”hidden”,”options”:[],”cols”:”12″,”conditions”:[],”wrapper_id”:”wrapper-8983-4113″,”field_label”:”Bank Account”,”default_value”:”custom_value”,”custom_value”:”bank_account_number”},{“id”:”select-1″,”element_id”:”select-1″,”form_id”:”wrapper-6464-1544″,”parent_group”:””,”type”:”select”,”options”:[{“label”:”918 Kiss”,”value”:”918-Kiss”,”limit”:””,”key”:”4853-4447″,”error”:””,”default”:””},{“label”:”Mega 888″,”value”:”Mega-888″,”limit”:””,”key”:”6606-4189″,”error”:””,”default”:””},{“label”:”pussy 888″,”value”:”pussy-888″,”limit”:””,”default”:””,”key”:”3715-9789″,”error”:””}],”cols”:”12″,”conditions”:[],”wrapper_id”:”wrapper-6464-1544″,”hidden_behavior”:”zero”,”value_type”:”single”,”field_label”:”Select”,”options_bulk_editor”:”918 Kiss;918-Kiss; 0\nMega 888;Mega-888; 0\npussy 888;pussy-888; 0″,”options_expanded”:”1″}],”settings”:{“pagination-header”:”nav”,”paginationData”:{“pagination-header-design”:”show”,”pagination-header”:”nav”},”formName”:”Deposit”,”version”:”1.28.1″,”form-border-style”:”none”,”form-padding”:””,”form-border”:””,”fields-style”:”open”,”field-image-size”:”custom”,”validation”:”on_submit”,”akismet-protection”:”0″,”form-style”:”default”,”enable-ajax”:”false”,”autoclose”:”true”,”submission-indicator”:”show”,”indicator-label”:”Submitting…”,”form-type”:”default”,”submission-behaviour”:”behaviour-thankyou”,”thankyou-message”:”Thank you for contacting us, we will be in touch shortly.”,”submitData”:{“custom-submit-text”:”Send Message”,”custom-invalid-form-message”:”Error: Your form is not valid, please fix the errors!”},”validation-inline”:”1″,”form-expire”:”no_expire”,”form-padding-top”:”0″,”form-padding-right”:”0″,”form-padding-bottom”:”0″,”form-padding-left”:”0″,”form-border-width”:”0″,”form-border-radius”:”0″,”cform-label-font-family”:”Roboto”,”cform-label-custom-family”:””,”cform-label-font-size”:”12″,”cform-label-font-weight”:”bold”,”cform-title-font-family”:”Roboto”,”cform-title-custom-family”:””,”cform-title-font-size”:”45″,”cform-title-font-weight”:”normal”,”cform-title-text-align”:”left”,”cform-subtitle-font-family”:”Roboto”,”cform-subtitle-custom-font”:””,”cform-subtitle-font-size”:”18″,”cform-subtitle-font-weight”:”normal”,”cform-subtitle-text-align”:”left”,”cform-input-font-family”:”Roboto”,”cform-input-custom-font”:””,”cform-input-font-size”:”16″,”cform-input-font-weight”:”normal”,”cform-radio-font-family”:”Roboto”,”cform-radio-custom-font”:””,”cform-radio-font-size”:”14″,”cform-radio-font-weight”:”normal”,”cform-select-font-family”:”Roboto”,”cform-select-custom-family”:””,”cform-select-font-size”:”16″,”cform-select-font-weight”:”normal”,”cform-multiselect-font-family”:”Roboto”,”cform-multiselect-custom-font”:””,”cform-multiselect-font-size”:”16″,”cform-multiselect-font-weight”:”normal”,”cform-dropdown-font-family”:”Roboto”,”cform-dropdown-custom-font”:””,”cform-dropdown-font-size”:”16″,”cform-dropdown-font-weight”:”normal”,”cform-calendar-font-family”:”Roboto”,”cform-calendar-custom-font”:””,”cform-calendar-font-size”:”13″,”cform-calendar-font-weight”:”normal”,”cform-button-font-family”:”Roboto”,”cform-button-custom-font”:””,”cform-button-font-size”:”14″,”cform-button-font-weight”:”500″,”cform-timeline-font-family”:”Roboto”,”cform-timeline-custom-font”:””,”cform-timeline-font-size”:”12″,”cform-timeline-font-weight”:”normal”,”cform-pagination-font-family”:””,”cform-pagination-custom-font”:””,”cform-pagination-font-size”:”16″,”cform-pagination-font-weight”:”normal”,”payment_require_ssl”:””,”submission-file”:”delete”,”store_submissions”:”1″,”form_name”:”deposit”,”form_status”:”publish”,”sc_email_link”:”1″,”sc_message”:”
    Your form has been saved as draft and a resume link has been generated so you can return to the form anytime within {retention_period} days from today. Copy and save the link or enter your email address below to have the link sent to your mail.
    These fields weren’t saved to your submission draft: Paypal, Stripe, Signature, Password, Captcha, and Upload. Kindly fill them out before submitting the form.
    “,”use-autofill”:””,”notification_count”:1,”previous_status”:”publish”,”use_ajax_load”:””,”use_donotcachepage”:”1″},”client_id”:null,”integration_conditions”:[],”behaviors”:[{“slug”:”behavior-1234-4567″,”label”:””,”autoclose-time”:”5″,”autoclose”:”true”,”newtab”:”sametab”,”thankyou-message”:”Thank you for contacting us, we will be in touch shortly.”,”email-thankyou-message”:””,”manual-thankyou-message”:””,”submission-behaviour”:”behaviour-thankyou”,”redirect-url”:””}],”notifications”:[{“slug”:”notification-1234-4567″,”label”:”Admin Email”,”email-recipients”:”default”,”recipients”:”[email protected]”,”email-subject”:”New Form Entry #{submission_id} for {form_name}”,”email-editor”:”You have a new website form submission:
    {all_fields}
    \n{upload-1}

    This message was sent from {site_url}.
    “,”email-attachment”:”true”,”type”:”default”,”conditions”:[]}]},”status”:”publish”,”version”:”1.28.1″}

    Thread Starter hydevelop1994

    (@hydevelop1994)

    oops sorry been paste it

    Thread Starter hydevelop1994

    (@hydevelop1994)

    hi how come there is no update while other threads have reply?

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @hydevelop1994 ,

    We didn’t receive a notification from the org forum about your response.
    You have to use pastebin.com or code tag in response or txt file uploaded on something like dropbox to share code.
    Right now with changed formatting, we can’t use it.

    kind regards,
    Kasia

    Thread Starter hydevelop1994

    (@hydevelop1994)

    {"type":"form","data":{"fields":[{"id":"upload-1","element_id":"upload-1","form_id":"wrapper-9142-3674","parent_group":"","type":"upload","options":[],"cols":"12","conditions":[],"wrapper_id":"wrapper-9142-3674","field_label":"Upload file","filetypes":["jpg|jpeg|jpe","png","webp","css","htm|html","dfxp","js"],"file-type":"single","file-limit":"unlimited","upload-limit":"5","filesize":"MB","custom-files":"1","use_library":"true","required":"1"},{"id":"hidden-1","element_id":"hidden-1","form_id":"wrapper-8983-4113","parent_group":"","type":"hidden","options":[],"cols":"12","conditions":[],"wrapper_id":"wrapper-8983-4113","field_label":"Bank Account","default_value":"custom_value","custom_value":"bank_account_number"},{"id":"select-1","element_id":"select-1","form_id":"wrapper-6464-1544","parent_group":"","type":"select","options":[{"label":"918 Kiss","value":"918-Kiss","limit":"","key":"4853-4447","error":"","default":""},{"label":"Mega 888","value":"Mega-888","limit":"","key":"6606-4189","error":"","default":""},{"label":"pussy 888","value":"pussy-888","limit":"","default":"","key":"3715-9789","error":""}],"cols":"12","conditions":[],"wrapper_id":"wrapper-6464-1544","hidden_behavior":"zero","value_type":"single","field_label":"Select","options_bulk_editor":"918 Kiss;918-Kiss; 0\nMega 888;Mega-888; 0\npussy 888;pussy-888; 0","options_expanded":"1"}],"settings":{"pagination-header":"nav","paginationData":{"pagination-header-design":"show","pagination-header":"nav"},"formName":"Deposit","version":"1.28.1","form-border-style":"none","form-padding":"","form-border":"","fields-style":"open","field-image-size":"custom","validation":"on_submit","akismet-protection":"0","form-style":"default","enable-ajax":"false","autoclose":"true","submission-indicator":"show","indicator-label":"Submitting...","form-type":"default","submission-behaviour":"behaviour-thankyou","thankyou-message":"Thank you for contacting us, we will be in touch shortly.","submitData":{"custom-submit-text":"Send Message","custom-invalid-form-message":"Error: Your form is not valid, please fix the errors!"},"validation-inline":"1","form-expire":"no_expire","form-padding-top":"0","form-padding-right":"0","form-padding-bottom":"0","form-padding-left":"0","form-border-width":"0","form-border-radius":"0","cform-label-font-family":"Roboto","cform-label-custom-family":"","cform-label-font-size":"12","cform-label-font-weight":"bold","cform-title-font-family":"Roboto","cform-title-custom-family":"","cform-title-font-size":"45","cform-title-font-weight":"normal","cform-title-text-align":"left","cform-subtitle-font-family":"Roboto","cform-subtitle-custom-font":"","cform-subtitle-font-size":"18","cform-subtitle-font-weight":"normal","cform-subtitle-text-align":"left","cform-input-font-family":"Roboto","cform-input-custom-font":"","cform-input-font-size":"16","cform-input-font-weight":"normal","cform-radio-font-family":"Roboto","cform-radio-custom-font":"","cform-radio-font-size":"14","cform-radio-font-weight":"normal","cform-select-font-family":"Roboto","cform-select-custom-family":"","cform-select-font-size":"16","cform-select-font-weight":"normal","cform-multiselect-font-family":"Roboto","cform-multiselect-custom-font":"","cform-multiselect-font-size":"16","cform-multiselect-font-weight":"normal","cform-dropdown-font-family":"Roboto","cform-dropdown-custom-font":"","cform-dropdown-font-size":"16","cform-dropdown-font-weight":"normal","cform-calendar-font-family":"Roboto","cform-calendar-custom-font":"","cform-calendar-font-size":"13","cform-calendar-font-weight":"normal","cform-button-font-family":"Roboto","cform-button-custom-font":"","cform-button-font-size":"14","cform-button-font-weight":"500","cform-timeline-font-family":"Roboto","cform-timeline-custom-font":"","cform-timeline-font-size":"12","cform-timeline-font-weight":"normal","cform-pagination-font-family":"","cform-pagination-custom-font":"","cform-pagination-font-size":"16","cform-pagination-font-weight":"normal","payment_require_ssl":"","submission-file":"delete","store_submissions":"1","form_name":"deposit","form_status":"publish","sc_email_link":"1","sc_message":"<p>Your form has been saved as draft and a resume link has been generated so you can return to the form anytime within {retention_period} days from today. Copy and save the link or enter your email address below to have the link sent to your mail.</p><p>These fields weren't saved to your submission draft: Paypal, Stripe, Signature, Password, Captcha, and Upload. Kindly fill them out before submitting the form.</p>","use-autofill":"","notification_count":1,"previous_status":"publish","use_ajax_load":"","use_donotcachepage":"1"},"client_id":null,"integration_conditions":[],"behaviors":[{"slug":"behavior-1234-4567","label":"","autoclose-time":"5","autoclose":"true","newtab":"sametab","thankyou-message":"Thank you for contacting us, we will be in touch shortly.","email-thankyou-message":"","manual-thankyou-message":"","submission-behaviour":"behaviour-thankyou","redirect-url":""}],"notifications":[{"slug":"notification-1234-4567","label":"Admin Email","email-recipients":"default","recipients":"[email protected]","email-subject":"New Form Entry #{submission_id} for {form_name}","email-editor":"<p>You have a new website form submission: <br>{all_fields}</p>\n<p>{upload-1} <br>---<br>This message was sent from {site_url}.</p>","email-attachment":"true","type":"default","conditions":[]}]},"status":"publish","version":"1.28.1"}
    Thread Starter hydevelop1994

    (@hydevelop1994)

    @wpmudev-support2 here you go

    Thread Starter hydevelop1994

    (@hydevelop1994)

    Thread Starter hydevelop1994

    (@hydevelop1994)

    Hi @hydevelop1994,

    Hope this message finds you well.

    We understand your enthusiasm and eagerness for your issue to be resolved promptly. However, it is important to understand that tagging the team members and adding multiple replies will not expedite the process.

    From your other ticket I tested this code:

    <?php
    add_filter('forminator_field_hidden_field_value', function ($value)
    {
    
        if (!is_user_logged_in())
        {
            return $value;
        }
    
        $user = wp_get_current_user();
    
        $user_data = get_userdata($user->ID);
    
        // To show all possible values
        //print_r($user_data);
        if (strpos($value, 'user_bio') !== false)
        {
    
            $value = $user_data->description;
            return $value;
    
        }
        elseif (strpos($value, 'user_website') !== false)
        {
    
            $value = $user_data->user_url;
            return $value;
    
        }elseif (strpos($value, 'bank_account_number') !== false)
        {
    
            $value = $user_data->bank_account_number;
            return $value;
    
        }
    
        return $value;
    
    }
    , 20, 1);

    Using your form I was able to reproduce the issue, File Upload field goes missing.

    In such case, I escalated this to our devs, since they do work on very complex issues we cannot give an ETA on a fix yet. We will update you on this topic on their progress.

    Best regards,
    Laura

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @hydevelop1994 ,

    We haven’t heard from you for over a week now, so it looks like the changed code provided by Laura worked for you.

    Feel free to re-open this topic if needed.

    Kind regards
    Kasia

    Hi @hydevelop1994,

    Sorry for me delay.

    Our Second Line Support provided this new code.

    add_filter('forminator_field_hidden_field_value', function ($value) {
    
        if ( ! is_user_logged_in() ) {
            return $value;
        }
    
        $user = wp_get_current_user();
    
        if ( strpos( $value, 'user_bio' ) !== false ) {
            $value = get_user_meta( $user->data->ID, 'description', true );
            return $value;
        } elseif ( strpos( $value, 'user_website' ) !== false ) {
            $value = $user->data->user_url;
            return $value;
        } elseif ( strpos( $value, 'bank_account_number' ) !== false ) {
            $value = get_user_meta( $user->data->ID, 'bank_account_number', true );
            return $value;
        }
    
        return $value;
    
    },20, 1);

    Please check and let us the results.

    Best regards,
    Laura

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Custom code made the file upload image url dissapear’ is closed to new replies.