Is there an easy way to check if a specific form has already been embedded in a page? Is there a helper gravity forms function for this where I can pass the form id?
Hello @kahoots - there is no filter in Gravity Forms for this specifically. However, this plugin has some interesting ways of checking to see if the page has a form embedded in it:
I’m not recommending you use that plugin, because it does not do what you need, specifically. I am recommending that you look at the plugin code for the various methods it uses to determine is a page has a form shortcode or a form block. You can browse the code here and maybe get some ideas to achieve your goal:
Look for the functions
find_gf_block (and others) specifically for the methods I am referring to.
Dang! Fresh Forms does a super thorough job of checking for forms. I’m impressed, @sacom!
@kahoots If you’re looking for a simpler solution that will catch most cases, here’s a snippet that extracts how GF checks for forms.
Awesome suggestions. Thank you. BTW the plan is to use this to warn content populators when they add duplicate forms to the page, since that is not supported and breaks the forms.
Thanks @david, coming from you that’s a great compliment