Get form ids on a page with multiple CF7 forms
-
I have multiple CF7 forms on a page. I would like to get the form ids for each of the forms using PHP. Based on the form id, I would like to add certain javascript codes on the page. I would like to have this code added to the template file, not the functions.php. This is what I have added on my footer.php file:
$cf7 = WPCF7_ContactForm::get_current(); $cf7_id = $cf7->id(); if ($cf7_id == "615") { // add javascript code } if ($cf7_id == "745") { // add javascript code }
It seems like
get_current()
method only returns the very last form on the page. I also tried thefind()
method but it returns all the form objects created using CF7. How do I resolve this?
- The topic ‘Get form ids on a page with multiple CF7 forms’ is closed to new replies.