• Does anyone know of a way to pass the value of an ACF field to a hidden field in Gravity Forms? I realize this is probably not the best place to post this, it’s not a ACF issue, but I’m so tired LOL! Spent a few hours and I’m fried…

    What I’m trying to accomplish:

    ACF field containing a URL == pass to a hidden field in a form located on a different page == use that hidden field to dynamically populate the Redirect URL field (for the confirmation).

    Basically I have a client that wants to force people to fill out a form for EVERY download that’s available.. and redirect to the download after the form is submitted (I know… don’t say it…)

    they will add new downloads regularly, so that link will always change.

    I know this is crazy, but anyone have any idea where I can find help for this? I’ve tried all the code I’ve found all over the internet, for dynamically populating fields using hooks, etc. etc. and nothing works!!

    thanks people!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Would love to know if you found a solution for this as I need the exact same functionality.

    • This reply was modified 6 years, 6 months ago by jerodbarlow. Reason: subscribing
    Thread Starter Treebeard

    (@malawimama)

    @jerodbarlow No I’m sorry ??

    I ended up having to create all separate forms with different confirmation pages. If anyone does know of a way, I’m still hoping for a solution too.

    Actually, I just figured out a solution that worked pretty well for me.

    1. Added a field to ACF where my client can paste in the final confirmation URL.
    2. Added the following to my functions.php file:

    function de_gforms_confirmation_dynamic_redirect( $confirmation, $form, $entry, $ajax ) {
    if ( $form[‘id’] == ‘ID OF FORM GOES HERE’ ) {
    $acfdata = get_field(‘ACF_FIELD_NAME_GOES_HERE’);
    $confirmation = array( ‘redirect’ => $acfdata );
    }

    return $confirmation;
    }

    add_filter( ‘gform_confirmation’, ‘de_gforms_confirmation_dynamic_redirect’, 10, 4 );

    Thread Starter Treebeard

    (@malawimama)

    NICE!! Is your ACF field on a different page then the form itself?

    Yes as I implemented an exit pop-up, which includes the form and is customizable on a page-by-page basis (with the ACF fields containing default values), so in this example it’s pulling in the current post’s ACF value.

    However, you can specify a specific post to pull from by adding that to this line:

    $acfdata = get_field(‘ACF_FIELD_NAME_GOES_HERE’);

    E.g. $acfdata = get_field(‘ACF_FIELD_NAME_GOES_HERE’, POST-ID-GOES-HERE);
    More Info on this here: https://www.advancedcustomfields.com/resources/get_field/

    You could also potentially just create an ACF field and apply it to every page with a default value for that URL, which could be more flexible.

    Thread Starter Treebeard

    (@malawimama)

    Hmmm. This is similar to what I had in mind, could almost work.

    What we have is a page with lots of different callouts, each one for a specific download. Right now, they each link to a different page with a form, but I’d like to link them all to the same form instead.

    If I had just the one form, then I could pass the ACF field for each download on the previous page (it would contain a link to the downloadable file), to a hidden field in the form. Then use that field for the redirect right after the form is submitted.

    The thing is, what if there are like 10 of these ACF fields on a page? It won’t know which one to pull from, so that’s my problem really. And since the client is always adding new downloads, that ACF field would need to be dynamic somehow, so I can’t target a ACF field id number or something.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Pass ACF field value to Gravity Forms hidden field?’ is closed to new replies.