BUG: Plugin won’t work with forms loaded via AJAX
-
The plugin will not work when gravity forms are loaded via an AJAX call.
The root cause of this are the is_admin() calls in the plugin.
For more information please refer to the following links to see why relying on is_admin() (when doing AJAX for example) it’s a bad idea:
1. https://facetwp.com/is_admin-and-ajax-in-wordpress/
2. https://dev.to/lucagrandicelli/why-isadmin-is-totally-unsafe-for-your-wordpress-development-1le1
3. https://www.pluginvulnerabilities.com/2016/05/13/security-tip-for-developers-the-is_admin-function-doesnt-tell-you-if-someone-is-an-administrator/I’ve stumbled upon this issue while working on a website which had the same form, once loaded normally (not via AJAX) and once more on another page, where the form was loaded via AJAX inside a popup.
How I fixed it (temporarily of course) ?
I added a get_is_admin() function to the plugin’s class:
function get_is_admin() {
return is_admin() && !wp_doing_ajax();
}and then I replaced all the is_admin() calls in the class with self::get_is_admin() calls.
Of course, now, I need to disable plugin updates too for this plugin, on the site I made this fix, until this issue is fixed.
- The topic ‘BUG: Plugin won’t work with forms loaded via AJAX’ is closed to new replies.