Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘[Resolved ] What is this 'ajax call callback (advanced)'?’ is closed to new replies.
With ‘fields’ you have this option ‘ajax call callback (advanced)’.
What is it used for and how to implement this?
For example, on registration the ajax callback for username is username_exists, which has a check inside userpro_side_validate() function in ajax.php file. That allows you to add dynamic ajax checks on fields you want and return errors if the fields do not match a specific condition, here’s the function
functions/ajax.php
1 2 3 4 5 6 7 8 9 10 11 12 |
function userpro_side_validate(){ extract($_POST); $output['error'] = ''; switch($ajaxcheck) { case 'username_exists': if (username_exists($input_value)){ $output['error'] = __('Username already taken.','userpro'); } else if ( strstr($input_value, '-')) { $output['error'] = __('Dashes not allowed in username.','userpro'); } break; |
Now this username_exists function tests the input, if username is taken, if dash (show error to user) you can extend it easily if you know php to disallow spaces, or maybe disallow special strings.. whatever you want, additionally you can also setup new checks on other fields to validate registration the way you like.
Hope this shortcode is clear, if not tell me I will extend it.
The topic ‘[Resolved ] What is this 'ajax call callback (advanced)'?’ is closed to new replies.