Ask your WordPress questions! Pay money and get answers fast! (more info)

Advanced Custom Fields - adding field data to Contact Form 7 WordPress

  • SOLVED

I'm using the [[LINK href="http://www.advancedcustomfields.com/"]]Advanced Custom Fields[[/LINK]] plugin, the [[LINK href="https://wordpress.org/plugins/contact-form-7/"]]Contact Form 7[[/LINK]] plugin, and the [[LINK href="https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/"]]Contact Form 7 Dynamic Text Extension[[/LINK]] plugin.

I'm trying to include the data from a custom field in the email that is sent by Contact Form 7.


I have a page with a repeater field that makes a gallery of artwork. Each artwork opens up in a modal window with a contact form 7 form in it.

The repeater field 'artist_gallery' has a sub-field, 'description' which I want to add as a hidden field to the contact form, so the receiver knows which artwork the contact form is coming from.

I've used the Contact Form 7 Text Extension plugin and it works to return the title if I use the title shortcode, but I can't get it to return the data from the custom field.

I've tried adding the field using this shortcode ([[LINK href="https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/"]]from here[[/LINK]]):

[dynamictext dynamicname "CF7_get_custom_field key='field_4'"]

'field_4' is the field key for the 'description' custom field - [[LINK href="http://cl.ly/image/1V3w1m1S0f3j"]]Screenshot[[/LINK]]



But when the form comes it doesn't return anything, I've also tried putting 'description' as the key but that doesn't return anything either.

Is there something I am missing?




Answers (3)

2015-04-22

Romel Apuya answers:

Hi,

this can be easily achieve using jquery. If you can show the page that would be great.
add me on skype: rrapuya

cheers,

Romel


Mike Sewell comments:

Hi Romel, you can see the site here, just click on any of the artworks for the modal window with the contact form: http://bit.ly/1zQjmXW


Romel Apuya comments:

Hi Mike,

From the artworks which is the 'description' sub field of the repeater?

is it <p>Days of the Week -1<br>
1994<br>
Color woodcut<br>
15h X 11.5w in.<br>
Edition of 50</p>


for example?? or you are not displaying it?


Mike Sewell comments:

Yes, the exact section you quoted is the description.


Romel Apuya comments:

here just a theory.
add this in your functions.php
If you can give me access then i can probably make changes.

<?php
add_action('wp_head','set_to_hidden');
function set_to_hidden(){
?>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type='text/javascript'>
/* <![CDATA[ */
jQuery.noConflict();
jQuery( document ).ready(function( $ ) {
$('.reveal-modal').each(function() {
var hidden_value = $(this).find('.small-12.medium-4.columns').find('p:first').html();
var regex = /<br\s*[\/]?>/gi;
hidden_value.html(str.replace(regex, "\n"));
$(this).find('.wpcf7-form').find('div:hidden:first').append('<input type="hidden" value="'+hidden_value+'" name="_description">');
});
});
/* ]]> */
</script>
<?php
}
?>


Mike Sewell comments:

What do I need to add in the contact form 7 area for this to work, a placeholder of some kind?


Romel Apuya comments:

no need for other edits.

2015-04-22

Navjot Singh answers:

Sorry. NA. Wrong answer.

2015-04-23

Reigel Gallarde answers:

with your current setup, try this tag in your form... [dynamictext dynamicname "CF7_POST key='dynamichidden-865'"]


Mike Sewell comments:

How would that get the description field though? I tested it and it returned blank.


Reigel Gallarde comments:

add me on skype. my id is reigel99