* @access public
* @return void
*/
-function customFieldsSaveFields( $entityID )
-{
+function customFieldsSaveFields( $entityID ){
global $wpdb;
echo $entityID;
// If no data for custom field then return
return false;
}
//echo "Trying to save entity of type $uid";
- print_r(customFieldsGetFields($entityID));
+// print_r(customFieldsGetFields($entityID));
// See if this memberInfo has current field data
$currentCustomFields = customFieldsGetFieldData( $entityID );
// Insert the custom field record
'%d',
'%s'
);
+ $sql = "SELECT * FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields WHERE required=1";
+ $required = $wpdb->get_results($sql);
+
+ if(!empty($required)){
+ foreach($required as $req){
+ $requiredFields[] = $req->id;
+ }
+ }
+ foreach($_REQUEST['glm_custom_field'] as $fieldID =>$fieldValue){
+ if( in_array( $fieldID,$requiredFields )){
+ if($fieldValue === ''){
+ return $_REQUEST['glm_custom_field'];
+ }
+ }
+ }
+
// Loop through the glm_custom_field array
foreach ( $_REQUEST['glm_custom_field'] as $fieldId => $fieldValue ) {
$fieldData =array(
- 'entity_id' => $entityID,
+ 'entity_id' => $entityID,
'field_id' => $fieldId,
'field_data' => wp_kses_post(stripslashes($fieldValue))
);
$fieldData,
array(
'entity_id' => $entityID,
- 'field_id' => $fieldId
+ 'field_id' => $fieldId
),
$fieldDataFormat,
'%d'
);
}
}
+ return true;
}
function customFieldsCloneFields( $oldId, $newId )
* @access public
* @return void
*/
-function customFieldsGetFields( $entityID, $where = ' AND true ' )
+function customFieldsGetFields( $entityID, $where = ' AND true ', $uid )
{
global $wpdb;
if ( !$entityID) {
return false;
}
- $data = array();
+ $data = array();
$sql = "
SELECT *
FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields
WHERE id IN (select field_id from ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data WHERE entity_id = %d)" . $where;
- $fieldData = $wpdb->get_results( $wpdb->prepare( $sql, $entityID ), ARRAY_A );
+ $fieldData = $wpdb->get_results( $wpdb->prepare( $sql, $uid ), ARRAY_A );
+ echo '<pre>', print_r($fieldData), '</pre>';
}
'required' => true,
'use' => 'a'
),
- // Entity ID (event, member, package)
- 'entity_id' => array (
- 'field' => 'entity_id',
- 'type' => 'integer',
- 'view_only' => false,
- 'use' => 'a'
- ),
// group id
'uid' => array (
'field' => 'uid',
if (isset($actionData)) {
$entityID = $actionData['entityID'];
$uid = $actionData['uid'];
+ $fieldFail = $actionData['cfData'];
}
switch ($option) {
}
require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php';
- $customFieldsData = customFieldsGetFieldData( $entityID );
+ // is array ensures that the data passed BAD
+ if(is_array($fieldFail)){
+ $customFieldsData = $fieldFail;
+ }else {
+ $customFieldsData = customFieldsGetFieldData( $entityID );
+ }
+
// Compile template data
$template_data = array(
'prefix' => 'glm_custom_field',
'customFields' => $customFields,
'customFieldsData' => $customFieldsData,
+ 'fieldFail' => $fieldFail,
'fieldTypes' => $this->config['custom_field_types'],
'haveCustomFields' => $haveCustomFields,
'uid' => $uid
unset( $_REQUEST['glm_action'] );
$content = $this->controller( 'management', 'fields', array( 'uid' => $uid ), true );
return $content;
-}, 10, 3 );
+}, 10, 2 );
/**
* Filter returns the html for the form segment
*/
-add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id ){
+add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id,$cfData = false ){
unset( $_REQUEST['glm_action'] );
// echo "CONTENT: " . $content . " UID: " . $uid . " ID: " . $id . '<br>';
- $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'entityID' => $id ), true);
+ $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'entityID' => $id,'cfData'=>$cfData ), true);
return $content;
-}, 10, 3 );
+}, 10, 4 );
/**
* Filter Captured Data Success Status
*
}
return $queryParts;
});
-add_filter('glm-member-db-save-custom-fields', function( $entityID, $uid ) {
+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, $uid );
- return true;
+ return customFieldsSaveFields( $entityID);
+
},
10,
1
admin_search BOOLEAN NOT NULL DEFAULT '0', -- If the field is added to member list filters.
required BOOLEAN NOT NULL DEFAULT '0', -- If the field is required.
uid varchar(255) NOT NULL DEFAULT '', -- id for the series of custom fields associated with an entity
- entity_id INT NULL, -- id for the specific field associated with an entity
PRIMARY KEY (id),
INDEX(field_name(20))
);
----
-ALTER TABLE {prefix}custom_fields ADD COLUMN entity_id INT NULL;
-
-----
-
CREATE INDEX entity_id ON {prefix}custom_field_data(entity_id);