Advertisement
chrishajer

Conditional redirect based on drop-down

Oct 14th, 2012
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. // http://www.gravityhelp.com/forums/topic/conditional-redirect-2#post-80796
  2. // change the 1 here to your form ID if you are not using form 1
  3. add_filter('gform_confirmation_1', 'conditional_confirmation', 10, 4);
  4.  
  5. function conditional_confirmation($confirmation, $form, $lead, $ajax){
  6.     // change the 1 here to your field if the unit numbers not field 1
  7.     $url = get_bloginfo();    // set a reasonable default in case we forget a unit
  8.     switch($lead[1]) {
  9.         case 'P0003':
  10.             $url = "http://google.com/?q=P0003";
  11.             break;
  12.         case 'P0097':
  13.             $url = "http://www.ask.com/whatever";
  14.             break;
  15.         case 'P0224':
  16.             $url = "http://maps.google.com/?q=P0224";
  17.             break;
  18.         case 'P0438':
  19.             $url = "http://google.com/?q=P0003";
  20.             break;
  21.         case 'P0883':
  22.             $url = "http://example.com/some-page/";
  23.             break;
  24.         case 'P0925':
  25.             $url = "http://example.org/somthing-for-P0925";
  26.             break;
  27.         case 'P0956':
  28.             $url = "http://web.com/whatever-for-unit-956";
  29.             break;
  30.         case 'P0976':
  31.             $url = "http://google.com/";
  32.             break;
  33.         case 'P1173':
  34.             $url = site_url();
  35.             break;
  36.         case 'P1179':
  37.             $url = "http://whitehouse.gov/help";
  38.             break;
  39.         case 'P1454':
  40.             $url = site_url() . '/whichever-url-for-this-unit/';
  41.             break;
  42.         case 'P3461':
  43.             $url = "http://yahoo.com/news";
  44.             break;
  45.     }
  46.     $confirmation = array('redirect' => $url);
  47.     return $confirmation;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement