CHECKING STATUS
I AM LISTENING TO
|

Gravity Forms PHP Trait to send notifications and execute hooks on demand

5. February 2019
.SHARE

Table of Contents

When performing tasks using the Gravity Forms API, handling notifications and hook execution on demand is something that becomes really handy.

<?php

trait GravityForm{
	
	
	function GravityForm_send_notifications($form_id, $entry_id){

	  // Get the array info for our forms and entries
	  // that we need to send notifications for
  
	  $form 	= RGFormsModel::get_form_meta($form_id);
	  $entry 	= RGFormsModel::get_lead($entry_id);
  
	  // Loop through all the notifications for the
	  // form so we know which ones to send
  
	  $notification_ids = array();
  
	  foreach($form['notifications'] as $id => $info){
  
		  array_push($notification_ids, $id);
  
	  }
  
	  // Send the notifications
  
	  GFCommon::send_notifications($notification_ids, $form, $entry);

	}
	
	function GravityForm_execute_hooks($form_id, $entry_id){
	
	
		$form 				= GFAPI::get_form( $form_id );
		$entry 				= GFAPI::get_entry( $entry_id );
		$registered_addons 	= GFAddOn::get_registered_addons( );
		
		foreach( $registered_addons as $reg){
			if(method_exists($reg, "get_instance")){
				
				$execute = $reg::get_instance();				
				
				foreach($registered_addons as $addon){					
					
					$execute->maybe_process_feed( $entry, $form);
				}
			}
		}
		
		return true;
	}
		
	
}

Enjoy coding ….

Let’s Talk!

Looking for a reliable partner to bring your project to the next level? Whether it’s development, design, security, or ongoing support—I’d love to chat and see how I can help.

Get in touch,
and let’s create something amazing together!

RELATED POSTS

This is my own task / project / workflow solution fully integrated into WordPress, which I began developing in 2025. After the recent cloud outages—and following a significant investment in the Asana ecosystem—I decided to build a robust, self-hosted WordPress solution featuring an almost complete Asana Sync API integration. I don’t have plans to make […]

UPDATED: Asana is a great project management tool, but for those who prioritize data privacy, control, and customization, self-hosted alternatives are a better option. In 2026, there are several robust and feature-rich self-hosted project management tools that can effectively replace Asana while giving you full control over your data. Here’s a look at some of […]

Inspired byGutenberg Blocks in Gravity Forms: Seamless Widget IntegrationGutenberg Blocks in Elementor: Seamless Widget IntegrationMeet the Isolated Block Editor – Gutenberg, Untethered – Integrated into Elementor The idea took over Once you start working on an idea its hard not to see all the other possibilities ;) The plugin automatically detects and replaces TinyMCE textareas […]

Alexander

I am a full-stack developer. My expertise include:

  • Server, Network and Hosting Environments
  • Data Modeling / Import / Export
  • Business Logic
  • API Layer / Action layer / MVC
  • User Interfaces
  • User Experience
  • Understand what the customer and the business needs


I have a deep passion for programming, design, and server architecture—each of these fuels my creativity, and I wouldn’t feel complete without them.

With a broad range of interests, I’m always exploring new technologies and expanding my knowledge wherever needed. The tech world evolves rapidly, and I love staying ahead by embracing the latest innovations.

Beyond technology, I value peace and surround myself with like-minded individuals.

I firmly believe in the principle: Help others, and help will find its way back to you when you need it.