Using Gravity Forms ‘gform_gfuser_object_init’ JavaScript event

The gform_gfuser_object_init Gravity Forms Javascript event was a hook that fired on the feed configuration page after the DOM had been loaded and the GFUser JavaScript object had been initialized.

However, this hook was removed in version 3.0 with no replacement.

Usage

<script type="text/javascript">
jQuery(document).on('gform_gfuser_object_init', function() {
// code to fire once the GFUser object has been initialized goes here
});
</script>

Parameters

No parameters are passed to this event; however, it is useful to note that the GFUser object is a global namespace and properties can be safely added to it from this event.

More information

See Gravity Forms Docs: gform_gfuser_object_init

Examples

Adding values to the GFUser object

This example shows how to add two values to the GFUser object and then call another function that processes these new properties.

<script type="text/javascript">
jQuery(document).on('gform_gfuser_object_init', function() {
// add buddypress properties to GFUser object
GFUser.buddypress_meta = <?php echo (!empty($config['meta']['buddypress_meta'])) ? GFCommon::json_encode($config['meta']['buddypress_meta']) : "[new BuddyPressMetaOption()]"; ?>;
GFUser.buddypress_options = <?php echo GFCommon::json_encode(self::get_buddypress_fields()); ?>;

CreateBuddyPressMetaOptions();
});
</script>

Note

Since this hook was removed in version 3.0, the provided example and usage are for historical reference only.