Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // http://www.gravityhelp.com/forums/topic/custom-input-mask-for-a-valid-url#post-157749
- // change the 338 to your form ID
- add_filter('gform_pre_submission_filter_338', 'force_http');
- function force_http($form) {
- // change the 3 to your field ID where the URL will be entered
- // change it a few lines further down as well
- // trim the whitespace first, then make it lowercase
- $haystack = strtolower(trim($_POST['input_3']));
- // check for http:// at the beginning of the string
- $needle = 'http://';
- // if the http:// is not at the beginning of the string, add it and modify the POST value
- if (substr($haystack, 0, 7) == $needle) {
- return $form;
- }
- else {
- $_POST['input_3'] = $needle . $haystack;
- return $form;
- }
- }
Add Comment
Please, Sign In to add comment