Your Location is: Home > Advanced-custom-fields

advanced custom field (ACF) Repeater + Contact Form 7

From: New View: 4439 gil hamer 


I have a Repeater field which creates "jobs" each job has title, text as sub-fields and also a contact form 7 form which sends jobs applications.

I want to add hidden field which will also send the sub-field "title" so whenever form is submitted we know which job the sender sent the application from

Tried to use:
Contact Form 7 Dynamic Text Extension

but it is not working with ACF as far as I'm concern any help will be appreciated

Best answer

you could use CF7's 'wpcf7_form_hidden_fields' filter before your form is displayed,

add_filter('wpcf7_form_hidden_fields', 'add_job_title');
function add_job_title($hidden){
 //$current_job is the currenlty job loaded.
 $hidden['job_title']= $current_job->sub_title;
 return $hidden;

when the form is submitted, $_POST['job_title'] will have the value of the hidden field.