SHARE
TWEET

Untitled

a guest Feb 18th, 2013 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function vp_remove_fields_for_pm_users($form) {
  3.         if(!is_user_logged_in()) return null;
  4.  
  5.         if ( current_user_can( 'pmprofessional' ) ) {
  6.                 $fields_to_hide = array('Zip Code');
  7.                 foreach($form['fields'] as $key=>$field) {
  8.                         if(in_array($field['label'], $fields_to_hide)) {
  9.                                 $form['fields'][$key]['isRequired'] = false;
  10.                                 unset($form['fields'][$key]);
  11.                         }
  12.                 }
  13.         }
  14.         return $form;
  15. }
  16. add_filter('gform_pre_render_' . VP_POSTER_PROFILE_FORM_ID, 'vp_remove_fields_for_pm_users');
  17.  
  18.  
  19. function vp_unvalidate_zipcode_for_pm_users($validation_result) {
  20.         $form = $validation_result["form"];
  21.        
  22.         if ( current_user_can( 'pmprofessional' ) ) {
  23.                 $fields_to_hide = array('Zip Code');
  24.                 foreach($form['fields'] as $key=>$field) {
  25.                         if(in_array($field['label'], $fields_to_hide)) {
  26.                                 $form['fields'][$key]['failed_validation'] = false;
  27.                         }
  28.                 }
  29.         }
  30.         $validation_result["form"] = $form;
  31.         return $validation_result;
  32. }
  33. add_filter('gform_validation_' . VP_POSTER_PROFILE_FORM_ID, 'vp_unvalidate_zipcode_for_pm_users');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top