-
Hello,
I’ve purchased your plugin few days ago and I’ve requested some help with a custom field validation.
I have IBAN field in user’s profile page. It should be 24 characters long and it should be validated as specified here http://en.wikipedia.org/wiki/International_Bank_Account_Number for Romania.For example RO49 AAAA 1B31 0075 9384 0000
As I understand these are the steps:
1. White spaces removal (if any) (result: RO49AAAA1B31007593840000)
2. Check if there are 24 characters (result: ok)
3. First four characters are moved at the end of the string (result: AAAA1B31007593840000RO49)
4. All the letters are converted to numbers as specified below (result: 1010101011131007593840000272449)
5. Algorithm MOD 97-10 (ISO 7064) is applied to the previous output and also divided by 97 it should be 1 for a valid IBAN.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 – 35Hi there!
You need to add ajax call back function to the field you want to validate. e.g. in field settings, call the ajax callback: iban_validate, now to process or validate this field in real-time, you need to add validation for this in ajax.php file
after switch($ajaxcheck) {
add:
case ‘iban_validate’:
// add validation on $input_value
// error returned as : $output[‘error’]
break;That’s the idea. You can see other checks to do similar.
If you want to validate pre form update if user somehow passed validation in JS.
Hook to add_action(‘userpro_pre_profile_update’, ‘my_custom_hook’, 9999, 2);
Now you can do a my custom hook function to check $form[‘customfield’] etc… and compare the value etc then you’re allowed to update the profile according to wrong/valid number
These are two possible ways. You can also run the check/hook after profile update. These hooks can be found in user-functions.php file.
Hope this answer helps
Hello,
can you expand more this, please?
Can you provide an example of how to validate pre form update, please? (just a working example, as you like)
Thanks
If you want to validate pre form update if user somehow passed validation in JS.
Hook to add_action(‘userpro_pre_profile_update’, ‘my_custom_hook’, 9999, 2);
Now you can do a my custom hook function to check $form[‘customfield’] etc… and compare the value etc then you’re allowed to update the profile according to wrong/valid number
These are two possible ways. You can also run the check/hook after profile update. These hooks can be found in user-functions.php file.
You must be logged in to reply to this topic.