As a temporary fix, I added this to <theme_dir>/footer.php
, just before </body></html>
:
<script>
jQuery('.gform_wrapper').show();
</script>
This will tell jQuery to show all divs with the .gform_wrapper
class.
I already tried moving wp_footer();
around and all other suggestions from here. and from other sites. Nothing worked. I also tried disabling cache, purging cache, removing plugins, etc. No JS errors. No forms being shown.
One thing I noticed is the problem only shows up when two conditions are met:
- User is not logged-in.
- The form uses conditional logic.
If any of the two are not there, the form loads fine.
I'll add more info here once I find out why this is happening.
Edit:
The main issue is that DOMContentLoaded
is not being fired. It will happen if not all http requests finish (like pending css, js, images, etc.). The following code (borrowed from https://mcmap.net/q/497118/-manually-dispatchevent-domcontentloaded) forces the event and shows the form.
window.document.dispatchEvent(new Event("DOMContentLoaded", {
bubbles: true,
cancelable: true
}));
I still don't know why this is happening, since there are no pending requests showing in console. Everything seems to be loading properly. I tried to copy the entire site to another server and it works there. This leads me to think it's something related with the host provider. Maybe some kind of cache.
For now, I'll leave that piece of code at the end of <theme>/footer.php
.