Advertisement
chrishajer

Strip white space and return first 8 characters

Sep 24th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. // http://www.gravityhelp.com/forums/topic/merger-tags-use-part-of-a-tag
  3. // change the 9 in the next line to your form ID
  4. add_action('gform_pre_submission_9', 'custom_company_id');
  5. function custom_company_id($form){
  6.     // change the 5 part of 'input_5' here to the field ID where you want to store the 8 character company name
  7.     // change the 2 part of 'input_2' at the end to the field ID where the full company name was submitted
  8.     // this will strip out all whitespace, then return the first 8 characters
  9.     $_POST['input_5'] = substr(preg_replace('/\s+/', '', rgpost('input_2')), 0, 8);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement