When performing tasks using the Gravity Forms API, handling notifications and hook execution on demand is something that becomes really handy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<?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; } } |
I am a full-stack developer. My expertise include:
I love programming, design and know my way around server architecture as well. I would never feel complete, with one of these missing.
I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest.
Apart from that, I am a peace loving guy who tries to have people around him that think the same. I truly believe in the principle: “If you help someone, someone will help you, when you need it."