Viewing 4 reply threads
  • Author
    Posts
    • #4891
      justin
      Member

      My 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');
        }
       
      }
    • #4900
      Steve
      Keymaster

      @justin– We were able to reproduce and will be working on a fix.

    • #4910
      Steve
      Keymaster

      We 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] key
      

      Let us know if that fixes the issue.

    • #4912
      justin
      Member

      Looks like it is working now. Thank you for helping me get it working again!

    • #4913
      Steve
      Keymaster

      Great! We’ve simplified most of the object arrays, so working with them in the future will be even easier.

      Closing ticket.

Viewing 4 reply threads
  • The topic ‘validate [0.9.9.6]’ is closed to new replies.