Forum Replies Created
-
AuthorPosts
-
justinMemberThe only other thing I can think of is that I have almost 2000 users in my database. Each user probably has 10-15 pieces of meta-data created by piklist. It said the script was successful, but maybe it error-ed out because of the size? The whole thing probably took 30 seconds, so that would be a lot of meta to zip through and update.
Would re-running the script cause any harm?
justinMemberThat works great. Thank you for your help.
justinMemberYea, this is legacy user_meta from myPHPAdmin after the script was run.
a:4:{s:8:"user_job";a:1:{i:0;s:4:"3467";}s:14:"user_job_start";a:1:{i:0;s:10:"2009-09-05";}s:16:"user_job_current";a:1:{i:0;a:1:{i:0;s:7:"job_old";}}s:12:"user_job_end";a:1:{i:0;s:10:"2010-07-08";}}If I go into a profile and save a user’s profile for this field, this is what is saved to my database, in the correct format:
a:1:{i:0;a:4:{s:8:"user_job";s:4:"3695";s:14:"user_job_start";s:10:"2014-09-11";s:16:"user_job_current";a:1:{i:0;s:11:"job_current";}s:12:"user_job_end";s:0:"";}}Thanks,
justinMemberI understand that the arrays were changed, and that is absolutely fine with me, and I think it is a lot better. I thought though that the script that 0.9.9.2 had that ran initially was suppose to change all of the old structures to the new array structure. What I am saying is that they did not change them. I would have to go into each of the user profiles and hit save in order for the array to be updated to the new structure.
I was letting you up know that the script did not seem to work. I have an ok solution right now by manually determining which type of structure it is and outputting it with the correct method. I was hoping though that you had a solution to transition all my old data to the new structure.
justinMemberDo I need to use sub-tabs like you did in the demo?
I did not include sub-tabs.This is my profile tab: user-flow-profile.php in the workflows folder
<?php /* Title: Profile Order: 1 Flow: User Workflow Page: profile.php, user-edit.php Default: true */This is my second tab: user-flow-general.php in the workflows folder
<?php /* Title: General Order: 20 Flow: User Workflow */
justinMember@Steve,
I think there is some miscommunication. Your first post pointed me in the right direction to fix the problem. I just posted back on this, in case anyone else was using the $field variable in the function how to properly use it and pull the value from it. I don’t see a problem with how the array is.
Thanks,
justinMember$field is being brought down by your function I am just passing it into my function. $field ends up being a large array. Here is the array that it prints out:
Array ( [field] => user_custom_url [type] => text [label] => URL of your profile [description] => [prefix] => 1 [scope] => user_meta [value] => Array ( [0] => Adams ) [capability] => [role] => [logged_in] => [add_more] => [sortable] => [choices] => [list] => 1 [position] => [template] => user_meta [wrapper] => [field_wrapper][/field_wrapper][field_label] [field][field_description_wrapper][field_description][/field_description_wrapper] [columns] => [embed] => [editable] => 1 [child_field] => [label_position] => before [conditions] => [options] => [on_post_status] => [on_comment_status] => [display] => [group_field] => [required] => [index] => [multiple] => [errors] => [attributes] => Array ( [class] => Array ( [0] => _user_meta_user_custom_url ) [title] => [alt] => [tabindex] => [columns] => [value] => ) [tax_query] => Array ( [include_children] => 1 [field] => term_id [operator] => IN ) [meta_query] => Array ( [compare] => = [type] => CHAR ) [validate] => Array ( [0] => Array ( [type] => custom_unique ) ) [name] => _user_meta[user_custom_url][] [id] => [request_value] => Array ( [0] => Adams ) [valid] => 1 )So I have to go into the first portion of the array value in order to get what was actually put into the text field. so $field[‘value’][0] is set when the user types into the text box and enters in this case “Adams”.
justinMemberSo I figured it out. It had to do with $field. It returns an array and you have to
$field['value'][0];to get the value of that field.If anyone wants the fixed code for an example of a validation rule here is the fixed code:
add_filter('piklist_validation_rules', 'check_if_unique', 11); function check_if_unique($validation_rules) { $validation_rules['custom_unique'] = array( 'type' => 'safe_text', 'callback' => 'my_validate_unique' ); return $validation_rules; } function my_validate_unique($file, $field, $arguments) { if (! empty($_GET['user_id']) && is_numeric($_GET['user_id']) ) { $user_profile_id = $_GET['user_id']; // Otherwise something is wrong. } else { $current_user = wp_get_current_user(); $user_profile_id = $current_user->ID; } $thereturned_field = $field['value'][0]; $duplicate_url = new WP_User_Query( array( 'meta_key' => 'user_custom_url', 'meta_value' => $thereturned_field, 'exclude' =>$user_profile_id ) ); $userscount = $duplicate_url->get_total(); if($userscount != 1 ) { return true; }else{ return __('is not unique and or used unsupported characters. ONLY letters and numbers.', 'Extreme'); } }September 21, 2015 at 4:50 pm in reply to: performance drop with lots of conditional statements #4383
justinMemberThat seemed to help a lot. Thank you for the help. It seemed to have really speed up the entire site. I am so glad, because I have absolutely loved your plugin and have been developing with it on this new site for 9 months.
You guys are the best!
September 21, 2015 at 3:44 pm in reply to: performance drop with lots of conditional statements #4380
justinMember@kevin Do you think I could get access to the beta? My site is having major speed issue.
justinMember@steve that is great to hear. I am also having some major resource issues. I look forward to the new version.
justinMemberYea it seems to work now.
Thank you very much Steve.
justinMemberThat works perfectly. Thanks for helping Steve.
justinMemberOk, So i figured out some things. If I change the variable to start in the first array [0] then I can use the template correctly.
Here is the front end code:
$user_jobs = get_user_meta($curauth->ID, 'user_jobs_group', false); piklist('template' . '/user_jobs_template', array('data' => $user_jobs[0], 'loop' => 'data'));Here is the template file:
<?php echo $data['user_job']; echo $data['user_job_start']; echo $data['user_job_current'][0]; echo $data['user_job_end']; ?>Thanks for the help.
justinMemberThat was close. My issue was actually the exact opposite of the reported bug, but putting in:
'label' => 'Past Trip' ,'public' => true ,'show_in_admin_all_list' => false ,'protected' => falseWorked as expected for me.
-
AuthorPosts