From: Steve Sutton Date: Tue, 5 Jul 2016 20:08:14 +0000 (-0400) Subject: Fix front hooks X-Git-Tag: v1.0.0^2~39 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=59f38feea7e8ea73a01ff8e0bc987c8d9f81880e;p=WP-Plugins%2Fglm-member-db-leads.git Fix front hooks adding to form to test what can be done. --- diff --git a/models/admin/management/leads.php b/models/admin/management/leads.php index 123238f..0e61bd3 100644 --- a/models/admin/management/leads.php +++ b/models/admin/management/leads.php @@ -115,6 +115,8 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement public function modelAction($actionData = false) { + //$leadForms = GFAPI::get_forms(); + //echo '
$leadForms: ' . print_r($leadForms, true) . '
'; // Compile template data $templateData = array( diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 00b947a..6bac904 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -29,51 +29,37 @@ // Inject things into gravity forms fields - This intercepts all GravityForms before displaying them add_filter( 'gform_pre_render', function($form) { -/* - - // for each field in the form - foreach ( $form['fields'] as $k => $v ) { - - // Check for a specific input field - in this case contact interests - // This must be the same field name for all forms that need this data - if ($v['inputName'] == 'contact_interest_options') { - - // Inject sample options - *** THIS SHOULD BE FROM THE DATABASE TABLE OF LEADS INTERESTS *** - $form['fields'][$k]['choices'] = array( - 0 => array( - 'text' => 'Skiing', - 'value' => '1', - 'isSelected' => false, - 'price' => false - ), - 1 => array( - 'text' => 'Boating', - 'value' => '2', - 'isSelected' => false, - 'price' => false - ), - 2 => array( - 'text' => 'Hiking', - 'value' => '3', - 'isSelected' => false, - 'price' => false - ) - ); - } - - } - -*/ - + //echo '
$form: ' . print_r($form, true) . '
'; + $newCheckbox = new GF_Field_Checkbox(); + $newCheckbox->label = 'Interest Fields'; + $newCheckbox->inputName = 'glm_assoc_interest'; + $newCheckbox->choices = array( + 0 => array( + 'text' => 'Skiing', + 'value' => '1', + 'isSelected' => false, + 'price' => false + ), + 1 => array( + 'text' => 'Boating', + 'value' => '2', + 'isSelected' => false, + 'price' => false + ), + 2 => array( + 'text' => 'Hiking', + 'value' => '3', + 'isSelected' => false, + 'price' => false + ) + ); + //echo '
$newCheckbox: ' . print_r($newCheckbox, true) . '
'; + $form['fields'][] = $newCheckbox; return $form; }); - -// Check all GravityForm submissions to see if they are a form that supplies leads -add_filter( 'gform_pre_render', function($form) { - - // Check for some key field (perhaps hidden) that indicates that the form contains lead information - - // Collect the leads data and store it using a data class - -}); +add_action( 'gform_after_submission', function( $entry, $form ){ + echo '
$entry: ' . print_r($entry, true) . '
'; + echo '
$form: ' . print_r($form, true) . '
'; + exit; +}, 10, 2);