Home Forums General Issues Shortcode usage with Gravity Forms


Shortcode usage with Gravity Forms

  • Good Afternoon,

    I am working on a client site to pre-populate data from ACF and John Huebner was able to help me out with that part (Thanks John!), however my clients wants one of his fields to be a link (it is a URL to a dropbox site) and the option within GF is not a link and cannot be formatted as one.

    So I was trying their HTML field, but it does not allow Pre-Population, in talking to their support person, they suggested that if the ACF field can be a shortcode that it should show up as a value which then can be showed as a link for client.

    Well, the shortcodes from ACF do not appear in the HTML field in Gravity Forms (I tried another plugin to generate a date, so we know the HTML field can handle shortcodes and GF support had me add code to enable usage of Shortcodes in their product)

    My question is “Am I using the shortcode correctly”? The documentation shows this shortcode example: [acf field="{$field_name}"]

    So I changed $field_name to $billing_site which is the ACF field populated. Is that all i need to change or is there more I need to do?

    Has anyone else had a similar issue with using shortcodes and Gravity Forms? Any solutions?

  • ACF only runs shortcodes on wysiwyg fields by default. In order to let the shortcode be run on another field you need to add a filter for that field and call do_shortcode
    the filter as I’m using it here is not documented. name and key are later additions.

    change acf_field_name to the field name where you want to include the shortcode. You may need to include the post id value in the shortcode you add to the acf field.

    add_filter('acf/format_value/name=acf_field_name', 'acf_field_do_shortcodes', 10, 3);
    function acf_field_do_shortcodes($value, $post_id, $field) {
      if ($value) {
       $value = do_shortcode($value);
      return $value;
  • Hi John,

    Thanks again for the response, I added the filter that you provided, still no luck getting it to appear in my html form….I will continue to look around and ask GF for more info (I may even just change my form from a URL to a text file then I may be able to work with it better)

    Thanks again for your information, it has been very helpful!


  • What version of ACF are you using?

  • Latest version (this is a local dev site I a working with to play around with the code before I copy/paste the code on live server for client.

  • I can’t say why it’s not working, you’ve got a lot of things going on. I’d start with double checking that each one is working. Probably do some echos and var dumps to see what’s happening at each step and what the variables are set to.

  • Same problem here. Just updated to the latest ACF and it broke.

  • What does the shortcode that’s being passed to the filter look like? More than likely the shortcode needs to include the post ID so it might be necessary to alter the shortcode before running it.

  • Dear,

    Please Change the add_flter to be add_filter


  • typos happen, code supplied by other users, including myself, may not have been tested and as in this case, are meant to be an example of the full code that can be seen if one bothers to follow the links that I also provided. I assume that those doing development can debug minor issues and will not simply be copying and pasting my code but also attempting to understand what it’s doing so that they can learn something.

  • Thanx John Huebner, I’ve just explained

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Shortcode usage with Gravity Forms’ is closed to new replies.