Advertisement
duck__boy

add_form_to_table()

Aug 2nd, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. /**
  2.  * Updates the wp_forms table whenever a user sends a form
  3.  */
  4. function add_form_to_table(){
  5.     global $wpdb;
  6.    
  7.     $sender_id = get_current_user_id();
  8.     $form_type = $_POST['form_name'];
  9.     $form_data = $_POST;
  10.     unset($form_data['submit']);
  11.     unset($form_data['action']);
  12.     unset($form_data['security']);
  13.     $date = date("d-m-y H:i:s", time());
  14.  
  15.     if(!is_serialized($form_data)) :
  16.         $data = serialize($form_data);
  17.     endif;
  18.    
  19.     $data = compact('sender_id', 'form_type', 'form_data', 'date');
  20.    
  21.     $wpdb->insert('wp_forms', $data);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement