PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Display form via ajax request and admin_ajax.php

  1. Situation: There is a custom post type that is calling the gravity forms shortcode, [gravityform id="1" name="Event Registration Default" title="false" description="false"], to display a form on the page. This custom post is being called by an ajax request to admin_ajax.php and dynamically replacing a portion of the current page.

    Problem: Because admin_ajax.php is the actual file that is requesting the content of the post and running the shortcode for the form via $content = apply_filters('the_content', get_the_content());, the form is being displayed in admin more when placed on the page. Form is disabled, admin icons and markup are being shown.

    Temporary Solution: adjust gravityforms.php to check if the requesting page is admin_ajax.php and set "IS_ADMIN" = false.

    if(!defined("IS_ADMIN") && RG_CURRENT_PAGE != 'admin-ajax.php')
    {
      define("IS_ADMIN",  is_admin());
    }
    else if (RG_CURRENT_PAGE === 'admin-ajax.php')
    {
      define("IS_ADMIN",  false);
    }

    i would like a better solution so that when upgrading gravityforms plugin I do not need to remember to make this edit within the plugin.

    Posted 13 years ago on Tuesday January 24, 2012 | Permalink
  2. Hi, insivia,

    We will take a look at this and see if it is something we want to include in a future release.

    Thanks.

    Posted 13 years ago on Monday February 6, 2012 | Permalink

This topic has been resolved and has been closed to new replies.