Okay
  Public Ticket #2549354
CF7 Dynamic Text to get ACF from CPT
Closed

Comments

  •  1
    acidoverride started the conversation

    Hi,

    So I have a custom loop for used cars for sale, one of the custom fields is for a ref number. I would like the "Enquire" link to open the page with the contact form on but automatically fill a field within the contact form with the unique ref number. In the past I have done this no problem using The CF7 Dynamic Text plugin and using a conditional statement in my custom page template....

    <?php
    global $post;
    echo '<a href="'; ?>
    <?php echo bloginfo('url'); ?>
    <?php
    echo '/enquiry-form?enquiry-type=' . get_field('ref') . '">ENQUIRE</a>';

    ?>

    ...and in the CF7 form...

    [dynamictext enquiry-type id:enquiry-type readonly "CF7_GET key='enquiry-type'"]

    I just cant figure out how to make this work within Elementor. I know I can pull in the ACF using the dynamic tag but that doesnt bring in the URL to the form and I cant add a before aspect and as far as I am aware I cant add PHP in the Link field in the button settings in Elementor.

    Any help would be greatly appreciated.

    Thanks

  •  675
    Neuron replied

    Hi,

    You can try the code snippets plugins for the PHP part, there's no way that you can include PHP in Elementor, that's for their safety reasons.

    - https://wordpress.org/plugins/code-snippets/

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Hi, Thanks for the response.

    I'm a little unsure how this will work....

    It seems this plugin just creates functions that run all the time. I just need to create a URL with the relevant attribute so that it automatically populates a field in the contact form. For example.....

    https://www.website.com/enquiry-form/?enquiry-type=BMU0717

    Where "enquiry-form" is the webpage and "enquiry-type=" is the CF7 Dynamic Text ID and "BMU0717" is the custom field pulled from the loop. 

    Hope that makes sense.

  •  675
    Neuron replied

    Hi,

    I am very sorry for the late reply, there weren't support agents which did know custom coding so they could not help.

    Unfortunately, I cannot find it proper documentation for the plugin, it seems like it does not work with hidden fields.

    Is this their official documentation, or there is anything else.

    https://sevenspark.com/docs/contact-form-7-dynamic-text-extension 

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Hi,

    No problem at all. I've been doing a little digging myself.

    The issue I have seems to be the passing of an ACF from the previous page. Getting an ACF from the existing page (the page with the form on) isn't a problem. Getting a specific ACF from the referral page (in this case a Used Car CPT single) to pass to the dynamic text field is where I'm struggling.

    As I've said previously, if I was hard coding this in my own template I would simply create the link on the single page by including the ACF.....

    href="www.website.com/enquiry-form?enquiry-type=' . get_field('ref') . '"

    This would then create the link/url....

    href="www.website.com/enquiry-form?enquiry-type=BMU0001" (for example)

    This would then fill in the dynamic text field with the ref number "BMU0001".

    I just need a way of pulling in that ACF into the link URL. Ideally if it was possible I could use the Dynamic Tag option in Elementor and just set the Before field to "www.website.com/enquiry-form?enquiry-type=" but I dont seem to have the option of a Before and After here?

    Thanks

  •  933
    Neuron replied

    Hi,

    We're so sorry for the late reply, somehow we missed your ticket.

    Can you please provide me with your WP-admin, so I will check how you're doing it and tell you exactly what to do, but when you sent it make sure to click on private so no one else could be able to view it.

    Feel free to ask for anything you need.

    Kind Regards


  •  1
    acidoverride replied

    I have settled for a work around. I have made it so it populates a hidden text field on the form with the referral URL instead of the vehicle reference number. At least that way the office staff will be able to refer to the vehicles webpage.

    If it turns out the ref number will work better. Once the site is live I will revisit this issue.

    Thanks for your help.

  •  933
    Neuron replied

    You are welcome anytime, feel free to ask for anything you need

    If you like our theme, please leave us a rate with 5 stars at ThemeForest, that would help us a lot.

    Kind Regards,
    NeuronThemes