From 180bb9ca23296e12b7695621224f847fd04acbc7 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Thu, 19 Oct 2017 16:27:28 -0400 Subject: [PATCH] Adding UID to the management form so it can be saved and displayed --- classes/customFieldPluginSupport.php | 1 + models/admin/management/fields.php | 7 +++++++ setup/adminHooks.php | 17 ++++++++--------- views/admin/management/fields.html | 13 +++++++++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/classes/customFieldPluginSupport.php b/classes/customFieldPluginSupport.php index c2f8c4a..647a947 100644 --- a/classes/customFieldPluginSupport.php +++ b/classes/customFieldPluginSupport.php @@ -21,6 +21,7 @@ function customFieldsSaveFields( $memberId ) if ( !isset( $_REQUEST['glm_custom_field'] ) ) { return false; } + //echo "Trying to save entity of type $uid"; // See if this memberInfo has current field data $currentCustomFields = customFieldsGetFields( $memberId ); diff --git a/models/admin/management/fields.php b/models/admin/management/fields.php index 2ce537a..ae387d6 100644 --- a/models/admin/management/fields.php +++ b/models/admin/management/fields.php @@ -132,6 +132,11 @@ class GlmMembersAdmin_management_fields extends GlmDataFieldsCustomFields if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']-0; } + $uid = 0; + + if (isset($actionData['uid'])) { + $uid = $actionData['uid']; + } switch ($option) { @@ -180,6 +185,7 @@ class GlmMembersAdmin_management_fields extends GlmDataFieldsCustomFields // Get list of Custom Fields $custom_fields = $this->getList(); + // echo "
" . print_r($custom_fields, true) . "
"; if ( isset($custom_fields) && $custom_fields && count( $custom_fields ) > 0 ) { $haveCustomFields = true; } @@ -192,6 +198,7 @@ class GlmMembersAdmin_management_fields extends GlmDataFieldsCustomFields 'custom_fields' => $custom_fields, 'field_types' => $this->config['custom_field_types'], 'haveCustomFields' => $haveCustomFields, + 'uid' => $uid ); // Return status, suggested view, and data to controller diff --git a/setup/adminHooks.php b/setup/adminHooks.php index dda3f48..cccf024 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -44,8 +44,7 @@ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ */ add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id ){ unset( $_REQUEST['glm_action'] ); - // $content = $this->controller( 'entity', 'fields', array( 'uid' => false, 'memberId' => false ), true ); - $content = $this->controller( 'entity', 'fields', array('uid'=>$uid, "memberId"=>$id), true ); + $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true ); return $content; }, 10, 3 ); /** @@ -157,14 +156,14 @@ add_filter('glm-member-db-admin-search-query', function() { } return $queryParts; }); -add_action( - 'glm-member-db-save-custom-fields', - function( $memberInfoId ){ - require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php'; - // this will save the member data - customFieldsSaveFields( $memberInfoId ); +add_filter('glm-member-db-save-custom-fields', function( $entityId ) { + require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php'; + // this will save the member data + //echo "uid = $uid"; + customFieldsSaveFields( $entityId ); + return true; }, - 1, + 10, 1 ); add_action( diff --git a/views/admin/management/fields.html b/views/admin/management/fields.html index 81a0b92..9cca065 100644 --- a/views/admin/management/fields.html +++ b/views/admin/management/fields.html @@ -38,6 +38,7 @@ +

* Required

Cancel @@ -107,6 +108,9 @@ ID Field Type + UID/Entity + Required + Admin Searchable   @@ -128,6 +132,15 @@ {$t.field_type.name} + + {$t.uid} + + + {$t.required.name} + + + {$t.admin_search.name} +
Delete
-- 2.17.1