function EWD_FEUP_Create_WP_FEUP_User($WP_User)
{
    $Email_Confirmation = get_option("EWD_FEUP_Email_Confirmation");
    $Admin_Approval = get_option("EWD_FEUP_Admin_Approval");
    $Default_User_Level = get_option("EWD_Default_User_Level");
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Use_Crypt = get_option("EWD_FEUP_Use_Crypt");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    if ($Use_Crypt == "Yes") {
        $User_Fields['User_Password'] = Generate_Password(EWD_FEUP_RandomString());
    } else {
        $User_Fields['User_Password'] = sha1(md5(EWD_FEUP_RandomString() . $Salt));
    }
    if ($Username_Is_Email == "Yes") {
        $User_Fields['Username'] = $WP_User->user_email;
    } else {
        $User_Fields['Username'] = $WP_User->user_login;
    }
    $User_Fields['User_Admin_Approved'] = "No";
    $User_Fields['User_Email_Confirmed'] = "No";
    $User_Fields['User_Date_Created'] = date("Y-m-d H:i:s");
    $User_Fields['Level_ID'] = $Default_User_Level;
    $User_Fields['User_WP_ID'] = $WP_User->ID;
    Add_EWD_FEUP_User($User_Fields);
}
function Handle_File_Upload($Field_Name)
{
    /* Test if there is an error with the uploaded file and return that error if there is */
    if (!empty($_FILES[$Field_Name]['error'])) {
        switch ($_FILES[$Field_Name]['error']) {
            case '1':
                $error = __('The uploaded file exceeds the upload_max_filesize directive in php.ini', 'EWD_FEUP');
                break;
            case '2':
                $error = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 'EWD_FEUP');
                break;
            case '3':
                $error = __('The uploaded file was only partially uploaded', 'EWD_FEUP');
                break;
            case '4':
                $error = __('No file was uploaded.', 'EWD_FEUP');
                break;
            case '6':
                $error = __('Missing a temporary folder', 'EWD_FEUP');
                break;
            case '7':
                $error = __('Failed to write file to disk', 'EWD_FEUP');
                break;
            case '8':
                $error = __('File upload stopped by extension', 'EWD_FEUP');
                break;
            case '999':
            default:
                $error = __('No error code avaiable', 'EWD_FEUP');
        }
    } elseif (empty($_FILES[$Field_Name]['tmp_name']) || $_FILES[$Field_Name]['tmp_name'] == 'none') {
        $error = __('No file was uploaded here..', 'EWD_FEUP');
    } else {
        $msg .= $_FILES[$Field_Name]['name'];
        //for security reason, we force to remove all uploaded file
        $target_path = ABSPATH . 'wp-content/uploads/ewd-feup-user-uploads/';
        //create the uploads directory if it doesn't exist
        if (!file_exists($target_path)) {
            mkdir($target_path, 0777, true);
        }
        $Random = EWD_FEUP_RandomString();
        $target_path = $target_path . $Random . basename($_FILES[$Field_Name]['name']);
        if (!move_uploaded_file($_FILES[$Field_Name]['tmp_name'], $target_path)) {
            //if (!$upload = wp_upload_bits($_FILES["Item_Image"]["name"], null, file_get_contents($_FILES["Item_Image"]["tmp_name"]))) {
            $error .= "There was an error uploading the file, please try again!";
        } else {
            $User_Upload_File_Name = $Random . basename($_FILES[$Field_Name]['name']);
        }
    }
    /* Return the file name, or the error that was generated. */
    if (isset($error) and $error == __('No file was uploaded.', 'EWD_FEUP')) {
        $Return['Success'] = "N/A";
        $Return['Data'] = __('No file was uploaded.', 'EWD_FEUP');
    } elseif (!isset($error)) {
        $Return['Success'] = "Yes";
        $Return['Data'] = $User_Upload_File_Name;
    } else {
        $Return['Success'] = "No";
        $Return['Data'] = $error;
    }
    return $Return;
}