function profile_update($userid)
 {
     require_once GDM_CLIENTS_CLASS;
     $gdm_clients = new gdm_clients();
     if (isset($_POST['gdm_client_categories'])) {
         $gdm_clients->initialize_client($userid);
         $gdm_clients->update_client($userid, array("categories" => $gdm_clients->get_entered_categories($_POST['gdm_client_categories']), "url" => $_POST['gdm_client_website']));
     } else {
         $gdm_clients->remove_client($userid);
     }
 }
 function gdm_blogger_save_metaboxes($post_id)
 {
     if (get_post_type($post_id) == "gdm_outgoing_posts") {
         // dont want to save this on the wrong post type
         if (current_user_can('edit_posts')) {
             // author metabox
             update_post_meta($post_id, "gdm_blogger_requested_client", sanitize_text_field($_POST['gdm_client_categories']));
             if (isset($_POST['gdm_blogger_tags'])) {
                 $tags = explode(",", $_POST['gdm_blogger_tags']);
                 for ($i = 0; $i < sizeof($tags); $i++) {
                     $tags[$i] = $this->remove_whitespace($tags[$i]);
                     $tags[$i] = ucwords($tags[$i]);
                 }
                 update_post_meta($post_id, "gdm_blogger_tags", $tags);
             }
             if (isset($_POST['gdm_categories_list'])) {
                 $categories = explode(",", $_POST['gdm_categories_list']);
                 for ($i = 0; $i < sizeof($categories); $i++) {
                     $categories[$i] = $this->remove_whitespace($categories[$i]);
                     $categories[$i] = ucwords($categories[$i]);
                 }
                 update_post_meta($post_id, "gdm_categories_list", $categories);
             }
         }
         if (current_user_can('edit_others_posts') && isset($_POST['gdm_blogger_approved'])) {
             // editor metabox
             $message = "Hello " . get_the_author() . ",\r\n";
             error_reporting(E_ALL);
             switch ($_POST['gdm_blogger_approved']) {
                 case "yes":
                     require_once GDM_CLIENTS_CLASS;
                     $clients = new gdm_clients();
                     $clients->initialize_client(get_post_field('post_author', $post_id));
                     $clients->set_schedule(get_post_field('post_author', $post_id), "pending", array($post_id));
                     wp_schedule_single_event(time() + 30, "gdm_blogger_post_processing");
                     // marks post for immediate processing (time+30sec)
                     $message .= "Great news! Your post '" . get_the_title($post_id) . "' has been approved for publishing!\r\n";
                     $message .= "Please note, that even though the post has been approved you will not recieve payment yet. ";
                     $message .= "Payment will be delivered after the post has been published.\r\n";
                     break;
                 case "no":
                     $message .= "This email was sent to notify you tat your post sumission ";
                     $message .= "for your post '" . get_the_title($post_id) . "' was rejected.\r\n";
                     break;
             }
             if ($_POST['gdm_blogger_notes'] != "" && $_POST['gdm_blogger_notes'] != "Notes:") {
                 $message .= "\r\nThe editor has left the following notes:\r\n";
                 $message .= $_POST['gdm_blogger_notes'];
             }
             // TODO send mail to author and not me and uncomment
             // wp_mail("*****@*****.**","Re: ".get_the_title($post_id),$message);
         }
     }
 }