php – Trouble Accessing Gravity Forms API (GFAPI)

I’m having trouble figuring out where I should be registering my function in such a way that I can access the Gravity Forms API (GFAPI). At first glance, this may appear to be native to Gravity Forms, but I think I’m just missing some basic understanding of how WordPress uses hooks and registers functions.

The error I’m trying to resolve is that class_exists(“GFForms”) returns false (i.e. my code can’t access the API) in a context where I want it to return true.

I’m trying to take an XML, parse it, and use some of the data to generate a gravity forms entry.
My starting point was the Gravity Forms Simple AddOn ( as, to my knowledge, this is the direction I probably need to head since I’m wanting to access the GFAPI (correct me if I’m wrong there).

1) To start, I create a bootstrap file responsible for making GravityForms aware of the AddOn (abcd_import.php):

 * Plugin Name: ABCD Utility
 * Plugin URI:
 * Description: Display content using a shortcode to insert in a page or post
 * Version: 1
 * Text Domain: abcd-import-utility
 * Author: me
 * Author URI:
define( 'GF_abcd_IMPORT_VERSION', '1.0' );
add_action( 'gform_loaded', array( 'abcd_Import_Bootstrap', 'load' ), 5 );
class abcd_Import_Bootstrap {
    public static function load() {
        if ( ! method_exists( 'GFForms', 'include_addon_framework' ) ) {
        require_once( 'class-abcd.php' );
        GFAddOn::register( 'GFabcdImport' );
function gf_abcd_import() {
    return GFabcdImport::get_instance();

2) The following class (in class-abcd.php) contains the function that creates a shortcode, which creates a form, which calls ‘process_xml.php’. Before I had it set up so that both the ‘add_abcd_import_fields’ and ‘add_shortcode’ functions were outside the class. When they were outside the class, I could add the shortcode which successfully added the form (but no API access).

// This file is responsible for the nuts and bolts of declaring the AddOn to Gravity Forms
// Additionally, it provides a framework for in-depth customization of settings in three places:
// 1) Forms > ABCD Importer (when plugin_page() is active) 
// 2) Forms > Settings > ABCD Importer
// 3) Forms > Form(i.e. Edit) > Settings > ABCD Importer
// Since this AddOn doesn't really have 'settings' in that it's supposed to handle stuff automatically,
// I've deactivated (commented) all of the settings fields. I've left them as I suspect I will probably 
// want to add field mapping later and this is probably where I need to do it (thus everything that is 
// currently commented will serve its purpose as example code later)

class GFabcdImport extends GFAddOn {
    protected $_version = GF_ABCD_IMPORT_VERSION;
    protected $_min_gravityforms_version = '1.9';
    protected $_slug = 'gfabcdimport';
    protected $_path = 'plugin-folder-path/abcd_import.php';
    protected $_full_path = __FILE__;
    protected $_title = 'ABCD Import Utility';
    protected $_short_title = 'ABCD Importer';
    private static $_instance = null;
    public static function get_instance() {
        if ( self::$_instance == null ) {
            self::$_instance = new GFabcdImport();
        return self::$_instance;
    public function init() {
        add_filter( 'gform_submit_button', array( $this, 'form_submit_button' ), 10, 2 );       
        add_shortcode('add-custom-form', 'add_abcd_import_fields');
    public function scripts() {
        $scripts = array(
                'handle'  => 'my_script_js',
                'src'     => $this->get_base_url() . '/js/my_script.js',
                'version' => $this->_version,
                'deps'    => array( 'jquery' ),
                'strings' => array(
                    'first'  => esc_html__( 'First Choice', 'gfabcdimport' ),
                    'second' => esc_html__( 'Second Choice', 'gfabcdimport' ),
                    'third'  => esc_html__( 'Third Choice', 'gfabcdimport' )
                'enqueue' => array(
                        'admin_page' => array( 'form_settings' ),
                        'tab'        => 'gfabcdimport'
        return array_merge( parent::scripts(), $scripts );
    public function styles() {
        $styles = array(
                'handle'  => 'gf_abcd_styles_css',
                'src'     => $this->get_base_url() . '/css/gf_abcd_styles.css',
                'version' => $this->_version,
                'enqueue' => array(
                    array( 'field_types' => array( 'poll' ) )
        return array_merge( parent::styles(), $styles );
    function form_submit_button( $button, $form ) {
        $settings = $this->get_form_settings( $form );
        if ( isset( $settings('enabled') ) && true == $settings('enabled') ) {
            $text   = $this->get_plugin_setting( 'mytextbox' );
            $button = "<div>{$text}</div>" . $button;
        return $button;
    //This adds an entry under Forms in the WP context menu
    /*public function plugin_page() {
       echo 'This page appears in the Forms menu';
    //This displays settings in the Forms context menu: Settings > ABCD Importer
    public function plugin_settings_fields() {
        return array(
                'title'  => esc_html__( 'ABCD Import Utility Settings', 'gfabcdimport' ),
                'fields' => array(
                        'name'              => 'mytextbox',
                        'tooltip'           => esc_html__( 'This is the tooltip', 'gfabcdimport' ),
                        'label'             => esc_html__( 'This is the label', 'gfabcdimport' ),
                        'type'              => 'text',
                        'class'             => 'small',
                        'feedback_callback' => array( $this, 'is_valid_setting' ),
    //This displays settings in Forms > Form(i.e. Edit) > Settings > ABCD Importer  (unused, so most of it is commented out)  
    public function form_settings_fields( $form ) {
        return array(
                'title'  => esc_html__( 'ABCD Importer Settings', 'gfabcdimport' ),
                'fields' => array(
                    /* big chunk of commented out code I don't need */
    //artifact from the skeleton
    public function settings_my_custom_field_type( $field, $echo = true ) {
        echo '<div>' . esc_html__( 'My custom field contains a few settings:', 'simpleaddon' ) . '</div>';
        // get the text field settings from the main field and then render the text field
        $text_field = $field('args')('text');
        $this->settings_text( $text_field );
        // get the checkbox field settings from the main field and then render the checkbox field
        $checkbox_field = $field('args')('checkbox');
        $this->settings_checkbox( $checkbox_field );
    public function is_valid_setting( $value ) {
        return strlen( $value ) > 5;

    function add_abcd_import_fields($atts) {    
        $Content = "<form id='abcd_form' method='post' action='..wp-contentpluginsplugin-folder-pathprocess_xml.php' enctype='multipart/form-data'>";
        $Content .= "<label id='abcd_form_label' for='abcd_form_select'>Form Type</label>";
        $Content .= "<select id='abcd_form_select' name='abcd_form_select' form='abcd_form'>";
        $Content .= "<option value='optA' selected>Option A</option>";
        $Content .= "<option value='optB'>Option B</option>";
        $Content .= "</select></br>";
        $Content .= "<label id='abcd_file_label' for='abcd_file'>File</label>";
        $Content .= "<input type='file' id='abcd_file' name='abcd_file'></br>";
        $Content .= "<input type='submit' id='abcd_submit_btn' name='abcd_submit_btn' value='Submit'>";
        $Content .= "</form>";
        return $Content;

    //public function add_custom_shortcode($atts){
        /* use (add-custom-form) as shortcode */
      //  add_shortcode('add-custom-form', 'add_abcd_import_fields');

3) The HTML form created from the shortcode calls ‘process_xml.php’ through it’s action attribute. At the end of this file I attempt to a call a function ‘generate_A’ which fails because GFForms is unavailable. Regardless of what I do (read: where I move my functions around, the filters I add, etc.), I can’t seem to get at the GFAPI. My only conclusion is that I’m just doing something dumb.

//initialize variables
$fileTmpPath = $fileName = $fileSize = $fileType = $fileNameCmps = $fileExtension = $newFileName = '';
$uploadFileDir = './tmpXML/';
$type = '';

function sanitize_inputs($data) {
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;

  if (isset($_POST('abcd_submit_btn')) && $_POST('abcd_submit_btn') == 'Submit') {
    if (isset($_FILES('abcd_file')) && $_FILES('abcd_file')('error') === UPLOAD_ERR_OK) {
        $fileTmpPath = $_FILES('abcd_file')('tmp_name');
        $fileName = $_FILES('abcd_file')('name');
        $fileSize = $_FILES('abcd_file')('size');
        $fileType = $_FILES('abcd_file')('type');
        $fileNameCmps = explode(".", $fileName);
        $fileExtension = strtolower(end($fileNameCmps));

        //sanitize filename
        $newFileName = md5(time() . $fileName) . '.' . $fileExtension;

        $allowedfileExtensions = array('xml');
        if (in_array($fileExtension, $allowedfileExtensions)) {
                // directory in which the uploaded file will be moved                
                $dest_path = $uploadFileDir . $newFileName;
                $type = sanitize_inputs($_POST('abcd_form_select'));
                if(move_uploaded_file($fileTmpPath, $dest_path))
                    $message ='File upload successful.';                    
                    $message = 'There was some error moving the file to upload directory. Please make sure the upload directory is writable by web server.';

function process_file($type, $XMLFile){
    $dom = new DOMDocument;    
    $jsonArr = array();
    $gravityArr() = null;

    //Pattern to identify elements with a name of "PXXX' where 'XXX' is an integer
    $pattern = '/P\d*/';
    //Cycle through the DOM elements and save what we want to an array in json format
    foreach($dom->getElementsByTagName('*') as $abcd_component){
            $jsonArr('name') = $abcd_component->getAttribute('name');
            $jsonArr('text') = $abcd_component->getAttribute('text');
            array_push($gravityArr, $jsonArr);
    switch ($type){
        case 'optA':
        case 'optB':
            //generate_B($gravityArr); //TODO

function generate_A($gravityArr){
    //$ABCDImport = new GFabcdImport; //doesn't work, can't access GFAPI
    if (class_exists("GFForms")) { //class_exists returns 'false'
        $test = new GFForms; //help me get here please :)
        $test2 = '';

Gratitude to anyone that can point me in the right direction on this. Thanks so much!

unity – Gravity is working in reverse

I am new to Game Development. In fact, this is my first project. I am trying to make a speed run/parkour game. I decided to start with movement and physics, and make the course later. Movement works fine, although gravity works in a unexpected way. Instead of holding the player down, it makes the player float up. I know JavaScript, CSS, HTML, and Python but not C#. So I got the code from a video. Here’s the link to the video: Here’s the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
    public CharacterController controller;

    public float speed = 12f;
    public float gravity = -9.81f;

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;

    Vector3 velocity;
    bool isGrounded;

    // Update is called once per frame
    void Update()
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if(isGrounded && velocity.y < 0)
            velocity.y = -2f;

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);


Please get back to me as soon as possible.

plugin gravity forms – Learndash Groups – function to list members of a group

I’m using Learndash 3.2.2 on WordPress 5.4.2.
I’ve written a php function that populates a Gravity form dropdown using get_users() to populate the dropdown with all subscribers. Works fine.
If there a function like get_users() that will return all the members of a learndash group?

Any advice would be appreciated – thank you.

php – Sanity Check Request on WordPress Problem involving Importing XML into Gravity Forms plugin

Disclaimer: This is a conceptual question and so I’m posting here rather than stackoverflow or wordpress.stackexchange

Okay, so I need to import XML data into WordPress and parse it to populate a form created with the Gravity Forms plugin.
A few notes:

  1. WP prohibits the uploading of XML files
  2. Only trusted users will have access to the page on which this functionality will live
  3. Data entry plugins are fair game to be apart of the process.
  4. I’m building this on the Divi theme
  5. The XML file in question will be ~4k lines
  6. This will rarely (if ever) be used from a mobile device

My current approach is this:

  1. Use a divi code block and some jQuery to harness the necessary input fields on a page. Like, a file picker, a drop-down or two to give the site some idea of which form it needs to format the data into (right now, it’s just one, but more will come), and a button.
  2. The user would then pick the file, and click the button to kick off the function. I’m thinking of doing most of the XML file processing client-side since javascript gives me access to xPath, and xmltojson. This would then be sent to the server via an AJAX call.
  3. The server would then handle the call, populate the form, and then notify the user on success/failure.

Other ideas

Create a plugin that creates a shortcode to inject the necessary file-upload field, type selectors, and button onto a page

Save the XML file as a .txt file and upload it anyway -> just have the php processing it on the other side expect it and handle it as xml (is php xml processing better or worse than javascript? Same? #stuffIneedtoResearch)

Create a stand-alone application in some other language (I’d probably pick java) to convert the xml to a flat file (this would be my answer if I discovered client-side xml processing was a bad idea).

Question: Is this approach okay? Terrible? Please let me know what would be better. Remember, I’m not asking for code here. I simply feel like there’s a few client-server concepts and best practices that I’m missing and would appreciate if someone would point me in the right direction.

game mechanics – Problems with gravity and box colliders in Unity 3D

I have a game character that can jump or roll in order to avoid obstacles. He is able to roll while on the ground and he can also roll while he is in the air after jumping. Everything was working fine when I made him roll. I want to make it so that when he rolls while he’s in the air after jumping, he would fall at a faster pace than if he was just falling normally. So I did this in my c# script:

IEnumerator IncGravAcc()
    Physics.gravity = new Vector3(0, -50f, 0);
    yield return new WaitForSeconds(2f);
    Physics.gravity = new Vector3(0, -9.8f, 0);

I call this coroutine in the function that runs when the down arrow is clicked. Everything is working fine. When he rolls while in the air, he falls at a faster than normal rate. However he doesn’t land properly and he just falls right through the platform like it’s not even there. Here’s a video to show what I mean:

I have a box collider, not set to isTrigger, on the player (you can see it, the green box, right underneath him in the video) and the player’s also a rigidbody. The platforms don’t have rigidbodies on them but they do have box colliders set to trigger. You can see the platform’s box collider in the relation to player’s box collider in the picture provided (the platform’s box collider is the larger one of course)Box Colliders

How do I get it so that the character doesn’t fall through? Please let me know if there’s anything else you need to know about the project. Thank you for helping me!

plugins – How to capture hidden values with Gravity Forms

I will be using the following code from ActiveProspects and what it do is basically pass some hidden values (in this case basically a dynamic url) to the server along with the form fields which we need to capture and store in our DB. Now I am using Gravity Forms with my WordPress site but I am unable to capture that data.

 <script type="text/javascript">
  (function() {
      var field = 'xxTrustedFormCertUrl';
      var provideReferrer = false;
      var invertFieldSensitivity = false;
      var tf = document.createElement('script');
      tf.type = 'text/javascript'; tf.async = true;
      tf.src = "" + ('https:' == document.location.protocol ? 's' : '') +
        '://' + escape(provideReferrer) + '&field=' + escape(field) + '&l='+new Date().getTime()+Math.random() + '&invert_field_sensitivity=' + invertFieldSensitivity;
      var s = document.getElementsByTagName('script')(0); s.parentNode.insertBefore(tf, s); }
    <img src="" />

The following image shows the hidden data and fields enter image description here

Now here’s a gravity forms help page which says how to pass dynamic data but I am not into php much so any help will be well appreciated. As per this help I have added the following code in my theme functions.php but I think its hard coded. So can anybody let me know how to capture this hidden field value and store it.

add_filter( 'gform_field_value_xxTrustedFormCertUrl', 'my_custom_population_function' );
function my_custom_population_function( $value ) {
    return 'Boom';

unity – Making pick up objects, with that have gravity

I am trying to create pickups, that appear after an enemy dies, and that the player can pick up, but I am running into some issues.

First of all, I want the pickups to be affected by gravity, so I need a rigidbody2d and a boxcollider2d (non-trigger), so this works.

enter image description here

Now, if I want to collect the pickups on contact, I need to make the layers for the loot and the player get in contact, so that they can interact.

enter image description here

Now, of course, I do not want to push the pickups around. I want to actually pick them up when I touch them, but the collider is not a trigger so I thought I would use OnCollisionEnter to handle this.

        void OnCollisionEnter2D(Collision2D other)
            var loot = other.gameObject.GetComponent<ILoot>();

            loot?.PickUp(gameObject); // Destroys also the pickup

While this works, I am still using a non-trigger collider, which means that there are some physics effects that are not desired. For instance, when I “jump” onto the pickups.

enter image description here

Notice the subtle, but still present, slowdown in the fall, when the player enters in touch with the pickups?

How could I solve this issue??

How can I change the color of selected checkboxes in Gravity Forms? [closed]

All I want to do is change the default color from blue to red for my selected checkboxes in Gravity forms. What stylesheet is this in, or how is this color able to be changed?

javascript – Write gravity forms field values to server file before submission

I have a gravity form and I want to write the values of the fields to a server file, before submission, to capture people who don’t finish the form. I know there is a partial entries add on but I wondered whether this would be possible using node js?

I was thinking of an onblur event that writes the field value to a file.

If this is possible, how would I link this to the gravity form itself ? Where do I place the code? Can’t put js in functions.php so maybe use the css class option on the fields ?

Any advice appreciated.

Gravity Forms – Prevent Multiple Form Entries Same User ID with Same Field Value

I have a form where users will submit a timecard.

  • All entries to this form will be from users who are logged in (this part I have figured out).
  • Users will enter their name, the amount of hours, and select the date for the timecard (week ending).
  • The issue I’m encountering is how to limit the form so that each user can only submit the form once for each week ending (the date field).
  • Every user should be able to submit a form for the same date, but only once per user.
  • I’m not limiting per time period, because perhaps they forgot a timecard for last week and and so they should be able to enter two form submissions back to back, one for this week and one for last week, but only one form submission per user, per date selected in the date field.

Any assistance would be greatly appreciated!