Tagged: 0.9.9.6, validation
- This topic has 4 replies, 2 voices, and was last updated 6 years, 3 months ago by
Steve.
Viewing 4 reply threads
-
AuthorPosts
-
-
November 6, 2015 at 12:39 pm #4891
justinMemberMy custom validation broke with the upgrade. In the past, it seemed I was able to grab the value as it was before, and the new value submitted, so that I could determine if it was unique. Now, all I am getting in the $field variable is the new submitted value. How would I get the value that the field was before the change?
This was my previous validation formula:
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) { $thereturned_field = $field['request_value'][0]; $duplicate_url = new WP_User_Query( array( 'meta_key' => 'user_custom_url', 'meta_value' => $thereturned_field, 'exclude' => $field['attributes']['title'] ) ); $userscount = $duplicate_url->get_total(); //return($field['attributes']['title'] . " - total - " . $userscount . "search -" . $thereturned_field); if($userscount == 0 ) { return true; }else{ return __('is not unique and or used unsupported characters. ONLY letters and numbers.', 'Extreme'); } } -
November 9, 2015 at 2:44 pm #4900
-
November 10, 2015 at 11:34 am #4910
SteveKeymasterWe added a lot more data for you to use in Validation rules. You should just have to change two lines:
function my_validate_unique($index, $value, $options, $field, $fields) { $thereturned_field = $field['request_value']; // remove the [0] keyLet us know if that fixes the issue.
-
November 10, 2015 at 2:19 pm #4912
justinMemberLooks like it is working now. Thank you for helping me get it working again!
-
November 10, 2015 at 4:02 pm #4913
SteveKeymasterGreat! We’ve simplified most of the object arrays, so working with them in the future will be even easier.
Closing ticket.
-
-
AuthorPosts
Viewing 4 reply threads
- The topic ‘validate [0.9.9.6]’ is closed to new replies.