Support

Account

Home Forums General Issues Returning a URL instead of a post ID from a File field

Solving

Returning a URL instead of a post ID from a File field

  • I’ve added an ACF custom field (of type File) to the Products pages on my web site. The field is called “asp_manual_url”, and it’s pointed to a PDF document in the Media Library.

    In a CF7 form, I’ve included this code:

    [dynamichidden manual_url "CF7_get_post_var key='asp_manual_url'"]

    In the email section of the CF7 form, I’ve added this HTML code:

    <p>Please <a href="[manual_url]">click here</a> to download the manual.</p>

    The general idea is that the user fills out a form, and they receive an email containing a download link for the manual.

    Unfortunately, the email doesn’t contain a proper URL, it contains what seems to be a post ID.

    If I change the custom field to type Text, and enter a full URL into that field, that full URL does appear in the email. However, that means that I have to work out the full URL and enter it – it’s easier to use a File type and select a file from the media library.

    I’m guessing that I need to make a change to the [dynamichidden] line so that it returns a URL instead of a post ID. Unfortunately, I’ve looked through all the docs and can’t find anything. Can anyone help?

  • ACF only stores the ID of the field for the meta_key/meta_value. CF7 (or the add on your using) is directly accessing the meta value and not going through ACF to get the value.

    In order to do this you’ll need to create your own shortcode to add here
    [dynamichidden manual_url "CF7_get_post_var key='asp_manual_url'"]
    instead of using the [dynamichidden] add on. Or, alternately if this shortcode allows filtering so that you can filter the value used in order to get the file url from the ID. You’ll need to ask the authors of the dynamic text extension if the value can be filtered.

  • Hi,

    I am having the exact same issue/question (just with a different form plugin). Were you able to sort this out with the help of the first reply?

    Thanks,

    Andreas

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

The topic ‘Returning a URL instead of a post ID from a File field’ is closed to new replies.