Home Forums WC Vendors Pro Support CUstom Filed Validator

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.


Thank you to all of our customers!


  • This topic has 5 replies, 3 voices, and was last updated 7 years ago by Yasa.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #55777

    Hi, how can I set validation on custom fields?

    For example on IBAN field I would like to check it with this function;

    function checkIBAN($iban)
        $iban = strtolower(str_replace(' ','',$iban));
        $Countries = array('al'=>28,'ad'=>24,'at'=>20,'az'=>28,'bh'=>22,'be'=>16,'ba'=>20,'br'=>29,'bg'=>22,'cr'=>21,'hr'=>21,'cy'=>28,'cz'=>24,'dk'=>18,'do'=>28,'ee'=>20,'fo'=>18,'fi'=>18,'fr'=>27,'ge'=>22,'de'=>22,'gi'=>23,'gr'=>27,'gl'=>18,'gt'=>28,'hu'=>28,'is'=>26,'ie'=>22,'il'=>23,'it'=>27,'jo'=>30,'kz'=>20,'kw'=>30,'lv'=>21,'lb'=>28,'li'=>21,'lt'=>20,'lu'=>20,'mk'=>19,'mt'=>31,'mr'=>27,'mu'=>30,'mc'=>27,'md'=>24,'me'=>22,'nl'=>18,'no'=>15,'pk'=>24,'ps'=>29,'pl'=>28,'pt'=>25,'qa'=>29,'ro'=>24,'sm'=>27,'sa'=>24,'rs'=>22,'sk'=>24,'si'=>19,'es'=>24,'se'=>24,'ch'=>21,'tn'=>24,'tr'=>26,'ae'=>23,'gb'=>22,'vg'=>24);
        $Chars = array('a'=>10,'b'=>11,'c'=>12,'d'=>13,'e'=>14,'f'=>15,'g'=>16,'h'=>17,'i'=>18,'j'=>19,'k'=>20,'l'=>21,'m'=>22,'n'=>23,'o'=>24,'p'=>25,'q'=>26,'r'=>27,'s'=>28,'t'=>29,'u'=>30,'v'=>31,'w'=>32,'x'=>33,'y'=>34,'z'=>35);
        if(strlen($iban) == $Countries[substr($iban,0,2)]){
            $MovedChar = substr($iban, 4).substr($iban,0,4);
            $MovedCharArray = str_split($MovedChar);
            $NewString = "";
            foreach($MovedCharArray AS $key => $value){
                    $MovedCharArray[$key] = $Chars[$MovedCharArray[$key]];
                $NewString .= $MovedCharArray[$key];
            if(bcmod($NewString, '97') == 1)
                return TRUE;
                return FALSE;
            return FALSE;

    How can I apply this to custom field validation?

    Thank you.


    And also I need minlength and only numbers on data-rules for another custom field, but couldn’t figure it out how to apply.


    While I do understand what you are trying to accomplish- I do not know how to work with this situation. This type of validation is not something I have worked with before, and I am not sure how to make the validator check the numeric entries to ensure they are a valid IBAN format after the form is submitted.
    I have passed this along to Jamie so he can take a look and reply if he has the chance..


    Thank you, what about minlength and only numbers?



    To get the iBan validation to work it would have to be in javascript and loaded in a separate file for this to work. I haven’t actually tried to do any custom validation using the advanced library that ships with the framework we use.

    Here is a link to the documentation for the validation library so that you can see how it works.


    With regards to your min length and only numbers you can also see how that is done from any of our existing fields that use the custom_attributes. You can have multiple rules in the same field by using | to chain them together.




    Thank you @digitalchild

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.