Advertisement
chrishajer

run code for form 11 or form 12

Sep 5th, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. add_action("gform_user_registered", "add_custom_user_meta", 10, 3);  
  2. function add_custom_user_meta($user_id, $config, $entry) {
  3.     // put form IDs into the $regforms array
  4.     // if not one of these forms, skip this code
  5.     $regforms = array(11,12);
  6.     if(!in_array($entry['form_id'], $regforms))
  7.         return;
  8.     // if it's form 11, run this code
  9.     if($entry['form_id'] == 11) {
  10.         wp_set_current_user( $user_id );
  11.         $user = wp_get_current_user();
  12.         $user->add_cap("access_s2member_ccap_creditexpertpro");
  13.     }
  14.     // if it's form 12, run this code
  15.     elseif($entry['form_id'] == 12) {
  16.                 wp_set_current_user( $user_id );
  17.                 $user = wp_get_current_user();
  18.         // change your capability name here to the one for form 12
  19.                 $user->add_cap("access_s2member_ccap_form12registrantcap");
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement