I'm not sure what's causing gravity forms $entry and $form parameters to return 1.
Here is my class.
namespace GrvityFormsIntegration\DataTools;
ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
defined( 'ABSPATH' ) or die( 'No direct access!' );
class GravityFormService {
public function __construct() {
/**
* I've also tried this without the init hook with the same results
*/
add_action('init', function() {
add_action( 'gform_after_submission', array($this, 'collectGFData'), 10, 2 );
});
} // end construct
public function collectGFData($entry, $form ) {
error_log("form was submitted");
ob_start();
var_dump($entry);
$entryTesting = ob_end_clean();
error_log("entry was $entryTesting");
ob_start();
var_dump($form);
$formTesting = ob_end_clean();
error_log("form was $formTesting");
$formID = rgar( $entry, 'form_id' );
$dateCreated = rgar( $entry, 'date_created' );
ob_start();
var_dump($dateCreated);
$dateCreatedTesting = ob_end_clean();
error_log("date created testing was $dateCreatedTesting");
ob_start();
var_dump($formID);
$formIDTesting = ob_end_clean();
error_log("form id testing was $formIDTesting");
} // end collectGFData
}
$gformService = new GravityFormService();
In my error log after submitting the form, I get the following in my log file:
[27-Feb-2021 20:17:02 UTC] form was submitted
[27-Feb-2021 20:17:02 UTC] entry was 1
[27-Feb-2021 20:17:02 UTC] form was 1
[27-Feb-2021 20:17:02 UTC] date created testing was 1
[27-Feb-2021 20:17:02 UTC] form id testing was 1
[27-Feb-2021 20:17:02 UTC] confirmation number testing was 1
Gravity forms version = 2.4.22
WordPress version = 5.6.2
PHP v. 7.4
Any help would be greatly appreciated - thanks!