예제 #1
0
 public static function wp_create_user($user_id, $user_name, $brought_by)
 {
     # Update Wp Db
     $u = new WpUsers();
     $u->ID = $user_id;
     $u->user_nicename = $user_name;
     $u->display_name = $user_name;
     $u->save();
     # Insert into mfr_db
     $sql = 'INSERT INTO `mfr_users` (`id`, `date_created`, `last_updated`, `level`, `coach`, `coaching_status`, `last_notification` , `last_chat_message` , `brought_by`) VALUES (?,?,?,?,\'0\',\'0\',\'0\',\'0\', ?)';
     $sql_time = time();
     $sql_level = '1';
     $stmt = \Mariana\Framework\Database::getConnection()->prepare($sql);
     $stmt->bindParam(1, $user_id);
     $stmt->bindParam(2, $sql_time);
     $stmt->bindParam(3, $sql_time);
     $stmt->bindParam(4, $sql_level);
     $stmt->bindParam(5, $brought_by);
     if ($stmt->execute()) {
         #creating the user files;
         $path = USER_PATH . DS . $user_id;
         if (mkdir($path, 0777)) {
             # Create notification files
             $file = fopen(USER_PATH . DS . $user_id . DS . "notify.txt", "w");
             fwrite($file, '');
             fclose($file);
             # Create user upload directory
             $path = UPLOAD_PATH . DS . $user_id;
             if (mkdir($path, 0777)) {
                 return true;
             }
         }
         return false;
     }
     return false;
 }