• Resolved Jan Mi?acky

    (@mirackygmailcom)


    Hello,
    I want to ask you whether or how to make the hidden fields send custom fields of the embedded page. I have found that I can get Page title meta data which is great, but I’d also like to be able to retrieve custom fields.

    I use ACF plugin.

    Thank you for your help!

    Best regardds,
    Jan

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @mirackygmailcom,

    Yes, you can do that too. You would need to create add a hidden field in the form first and then edit the post data field and enable custom fields section. There should be an option to select the hidden field you selected. Here is a screenshot for the same:

    https://monosnap.com/file/3OZ3g0RVrvWPm9NnYm9DWpMMLujci4

    If you are looking to something else or if I missed something, I apologise for the same and request you to elaborate a bit more on it.

    Thank you,
    Prathamesh Palve

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @mirackygmailcom,

    I gave a second thought and I thought you are looking to retrieve data. In that case, you can use the following mu-plugin:

    <?php
    add_filter( 'forminator_field_hidden_field_value', function( $value, $saved_value, $field ){
    	if( ! empty( $field['default_value'] ) && 'custom_value' === $field['default_value'] && strpos( $value, 'acf_' ) !== false ){
    		$field_keys = explode('acf_', $value );
    		$post_id = false;//default is current post/page
    		$value = get_field( $field_keys[1], $post_id );
    	}
    	return $value;
    }, 10, 3 );

    After add this custom code, you can add in a hidden field this custom value acf_[field_key], e.g: acf_job_title

    Let me know your views on it.

    Thank you,
    Prathamesh Palve

    Thread Starter Jan Mi?acky

    (@mirackygmailcom)

    Hi Prathamesh,
    the second reply is what I was looking for and it works perfectly! Thank you very much. I appreciate your help! You have just made my life so much easier (and automated).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hidden field getting data from ACF’ is closed to new replies.