function Insert_Forgot_Password_Form($atts)
{
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_user_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'loggedin_page' => '/', 'reset_email_url' => '', 'submit_text' => __('Reset password', 'EWD_FEUP')), $atts));
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $User = new FEUP_User();
    if ($User->Is_Logged_In()) {
        FEUPRedirect($loggedin_page);
    }
    $ReturnString = "";
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    $ReturnString .= "<div id='ewd-feup-forgot-password-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-forgot-password-form' class='pure-form pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-reset-email-url' value='" . $reset_email_url . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='forgot-password'>";
    $ReturnString .= "<div class='pure-control-group'>";
    $ReturnString .= "<label for='Email' id='ewd-feup-reset-password' class='ewd-feup-field-label'>" . __('Email', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='email' class='ewd-feup-text-input pure-input-1-3' name='Email' value='' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Reset_Password_Submit' value='" . $submit_text . "'></div>";
    $ReturnString .= "</div>";
    return $ReturnString;
}
Beispiel #2
0
function Insert_Logout($atts)
{
    // Include the required global variables, and create a few new ones
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $CookieName = urlencode("EWD_FEUP_Login" . "%" . sha1(md5(get_site_url() . $Salt)));
    $feup_Label_Successful_Logout_Message = get_option("EWD_FEUP_Label_Successful_Logout_Message");
    if ($feup_Label_Successful_Logout_Message == "") {
        $feup_Label_Successful_Logout_Message = __("You have been successfully logged out.", "EWD_FEUP");
    }
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('no_message' => '', 'redirect_page' => '#', 'no_redirect' => 'No', 'submit_text' => 'Logout'), $atts));
    if ($no_redirect != "Yes" and isset($_COOKIE[$CookieName])) {
        $redirect_page = get_the_permalink();
    }
    setcookie($CookieName, "", time() - 3600, "/");
    $_COOKIE[urldecode($CookieName)] = "";
    if ($redirect_page != "#") {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= EWD_FEUP_Add_Modified_Styles();
    $ReturnString .= "<div class='feup-information-div'>";
    $ReturnString .= $feup_Label_Successful_Logout_Message;
    $ReturnString .= "</div>";
    if ($no_message != "Yes") {
        return $ReturnString;
    }
}
function Auto_Login($atts)
{
    global $user_message, $feup_success;
    session_start();
    $username = $password = "";
    if (array_key_exists('Username', $_SESSION)) {
        $username = $_SESSION['Username'];
    }
    if (array_key_exists('User_Password', $_SESSION)) {
        $password = $_SESSION['User_Password'];
    }
    // Include the required global variables, and create a few new ones
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $Time = time();
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'redirect_field' => '', 'redirect_array_string' => '', 'submit_text' => __('Login', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($feup_success and $redirect_field != "") {
        $redirect_page = Determine_Redirect_Page($redirect_field, $redirect_array_string, $redirect_page);
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-login-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    //    $ReturnString .= "<br/>Logging you in...<br/>";
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-login-form' class='pure-form pure-form-aligned hidden'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='login'>";
    $ReturnString .= "<div class='pure-control-group'>";
    if ($Username_Is_Email == "Yes") {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label'>" . __('Email', 'EWD_FEUP') . ": </label>";
        $ReturnString .= "<input type='email' class='ewd-feup-text-input' name='Username' value='{$username}' placeholder='" . __('Email', 'EWD_FEUP') . "...'>";
    } else {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label'>" . __('Username', 'EWD_FEUP') . ": </label>";
        $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username'  value='{$username}' placeholder='" . __('Username', 'EWD_FEUP') . "...'>";
    }
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='pure-control-group'>";
    $ReturnString .= "<label for='Password' id='ewd-feup-login-password-div' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password' value='{$password}'>";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='pure-control-group'>";
    $ReturnString .= "<label for='Submit'></label><input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Login_Submit' '" . $submit_text . "'>";
    $ReturnString .= "</div>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    wp_enqueue_script('auto-login-script', '/wp-content/js/auto-login.js', array('jquery'));
    return $ReturnString;
}
function Insert_Reset_Password_Form($atts)
{
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_user_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Time = time();
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'submit_text' => __('Update Account', 'EWD_FEUP')), $atts));
    $CheckCookie = CheckLoginCookie();
    if ($CheckCookie['Username'] == "") {
        $ReturnString .= __('You must be logged in to access this page.', 'EWD_FEUP');
        if ($login_page != "") {
            $ReturnString .= "<br />" . __('Please', 'EWD_FEUP') . " <a href='" . $login_page . "'>" . __('login', 'EWD_FEUP') . "</a> " . __('to continue.', 'EWD_FEUP');
        }
        return $ReturnString;
    }
    /*$Sql = "SELECT * FROM $ewd_feup_fields_table_name ";
    	$Fields = $wpdb->get_results($Sql);*/
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-profile-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-edit-profile-form' class='pure-form pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='edit-account'>";
    $ReturnString .= "<input type='hidden' name='Username' value='" . $User->Username . "'>";
    $ReturnString .= "<div id='ewd-feup-register-username-div' class='ewd-feup-field-label'>" . __('Email', 'EWD_FEUP') . ": " . $User->Username . "</div>";
    $ReturnString .= "<div class='pure-control-group'>";
    $ReturnString .= "<label for='User_Password' id='ewd-feup-edit-password' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password' class='ewd-feup-text-input pure-input-1-3' value='' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='pure-control-group'>";
    $ReturnString .= "<label for='Confirm_User_Password' id='ewd-feup-edit-confirm-password' class='ewd-feup-field-label'>" . __('Repeat Password', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='Confirm_User_Password' class='ewd-feup-text-input pure-input-1-3' value='' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Edit_Password_Submit' value='" . $submit_text . "'></div>";
    $ReturnString .= "</div>";
    $ReturnString .= "</form>";
    return $ReturnString;
}
function Insert_Login_Form($atts)
{
    global $user_message, $feup_success;
    // Include the required global variables, and create a few new ones
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $Time = time();
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'redirect_field' => '', 'redirect_array_string' => '', 'submit_text' => __('Login', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= EWD_FEUP_Add_Modified_Styles();
    if ($feup_success and $redirect_field != "") {
        $redirect_page = Determine_Redirect_Page($redirect_field, $redirect_array_string, $redirect_page);
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-login' class='ewd-feup-login-form-div' class='ewd-feup-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-login-form' class='pure-form pure-form-aligned feup-pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='login'>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    if ($Username_Is_Email == "Yes") {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label ewd-feup-login-label'>" . __('Email', 'EWD_FEUP') . ": </label>";
        $ReturnString .= "<input type='email' class='ewd-feup-text-input ewd-feup-login-field' name='Username' placeholder='" . __('Email', 'EWD_FEUP') . "...'>";
    } else {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label ewd-feup-login-label'>" . __('Username', 'EWD_FEUP') . ": </label>";
        $ReturnString .= "<input type='text' class='ewd-feup-text-input ewd-feup-login-field' name='Username' placeholder='" . __('Username', 'EWD_FEUP') . "...'>";
    }
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Password' id='ewd-feup-login-password-div' class='ewd-feup-field-label ewd-feup-login-label'>" . __('Password', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input ewd-feup-login-field' name='User_Password'>";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Submit'></label><input type='submit' class='ewd-feup-submit ewd-feup-login-submit feup-pure-button feup-pure-button-primary' name='Login_Submit' value='" . $submit_text . "'>";
    $ReturnString .= "</div>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    return $ReturnString;
}
function Insert_Confirm_Forgot_Password($atts)
{
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_user_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $CheckCookie = CheckLoginCookie();
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Time = time();
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'submit_text' => __('Change password', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-profile-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-edit-profile-form' class='feup-pure-form pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='confirm-forgot-password'>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Email' id='ewd-feup-edit-password' class='ewd-feup-field-label'>" . __('Email', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='email' class='ewd-feup-text-input' name='Email' class='ewd-feup-text-input' value='" . $_GET['add'] . "' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Resetcode' id='ewd-feup-edit-password' class='ewd-feup-field-label'>" . __('Reset code', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Resetcode' class='ewd-feup-text-input' value='" . $_GET['rc'] . "' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='User_Password' id='ewd-feup-edit-password' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password' class='ewd-feup-text-input' value='' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Confirm_User_Password' id='ewd-feup-edit-confirm-password' class='ewd-feup-field-label'>" . __('Repeat Password', 'EWD_FEUP') . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='Confirm_User_Password' class='ewd-feup-text-input' value='' />";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit feup-pure-button feup-pure-button-primary' name='Edit_Password_Submit' value='" . $submit_text . "'></div>";
    $ReturnString .= "</div>";
    $ReturnString .= "</form>";
    return $ReturnString;
}
Beispiel #7
0
function Try_Now($atts)
{
    // Include the required global variables, and create a few new ones
    global $wpdb, $post, $user_message, $feup_success;
    global $ewd_feup_fields_table_name;
    global $redirect_field, $redirect_array_string, $redirect_page;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $Time = time();
    $Sql = "SELECT * FROM {$ewd_feup_fields_table_name} ORDER BY Field_Order";
    $Fields = $wpdb->get_results($Sql);
    $ReturnString = "";
    if (isset($_GET['ConfirmEmail'])) {
        ConfirmUserEmail();
    }
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'redirect_field' => "", 'redirect_array_string' => "", 'submit_text' => __('Register', 'EWD_FEUP')), $atts));
    if (isset($_GET['ConfirmEmail'])) {
        $ConfirmationSuccess = ConfirmUserEmail();
    }
    if ($feup_success and $redirect_field != "") {
        $redirect_page = Determine_Redirect_Page($redirect_field, $redirect_array_string, $redirect_page);
    }
    if ($feup_success and $redirect_page != '#') {
        //brian autologin
        session_start();
        $_SESSION['Username'] = $_REQUEST['Username'];
        $_SESSION['User_Password'] = $_REQUEST['User_Password'];
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if (!isset($ConfirmationSuccess)) {
        $ReturnString .= "<div id='ewd-feup-register-form-div'>";
        $ReturnString .= <<<HTML
<p class="terms_cond"><i>Get your 3-day free trial now.  No credit card required!</i></p>
HTML;
        if (isset($user_message['Message'])) {
            $ReturnString .= "<span id='signup_error_message' class='error-message'>" . $user_message['Message'] . "</span>";
        }
        $ReturnString .= "<form action='#' name='ewd-feup-register-form' method='post' id='ewd-feup-register-form' class='pure-form pure-form-aligned' enctype='multipart/form-data' data-toggle='validator' novalidate>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='register'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-post-id' value='" . $post->ID . "'>";
        $ReturnString .= '
        <div class="pure-control-group">
        <label for="Phone" id="ewd-feup-register-4"
                                               class="ewd-feup-field-label">Phone: </label><input name="Phone"
                                                                                                  id="ewd-feup-register-input-4"
                                                                                                  class="ewd-feup-text-input pure-input-1-3"
                                                                                                  type="tel"
                                                                                                  placeholder="Phone"
                                                                                                  data-inputmask="\'mask\': \'9999999999\'"
                                                                                                  required=""></div>
        <div class="pure-control-group"><label for="Gender" id="ewd-feup-register-11" class="ewd-feup-field-label" required>Gender: </label><select
                name="Gender" id="ewd-feup-register-input-11" class="ewd-feup-select pure-input-1-3" required>
                <option value="Female" selected>- Gender -</option> 
                <option value="Female" >Female</option>
                <option value="Male">Male</option>
                <!--<option value="Other">Other</option>-->
            </select></div>


';
        $ReturnString .= "<div class='pure-control-group hidden'>";
        if ($Username_Is_Email == "Yes") {
            $ReturnString .= "<label for='Username' id='ewd-feup-register-username-div' class='ewd-feup-field-label'>Hidden username</label>";
            if (isset($_POST['Username'])) {
                $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' required=false value='" . $_POST['Username'] . "'>";
            } else {
                $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' required=false placeholder='" . __('Email', 'EWD_FEUP') . "...'>";
            }
        } else {
            $ReturnString .= "<label for='Username' id='ewd-feup-register-username-div' class='ewd-feup-field-label'>Hidden username</label>";
            if (isset($_POST['Username'])) {
                $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' required=false value='" . $_POST['Username'] . "'>";
            } else {
                $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' required=false placeholder='" . __('Username', 'EWD_FEUP') . "...'>";
            }
        }
        $ReturnString .= "</div>";
        $ReturnString .= "<div class='pure-control-group hidden'>";
        $ReturnString .= "<label for='Password' id='ewd-feup-register-password-div' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . ": </label>";
        if (isset($_POST['User_Password'])) {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password' value='" . $_POST['User_Password'] . "'>";
        } else {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password'>";
        }
        $ReturnString .= "</div>";
        $ReturnString .= "<div class='pure-control-group hidden'>";
        $ReturnString .= "<label for='Repeat Password' id='ewd-feup-register-password-confirm-div' class='ewd-feup-field-label'>" . __('Repeat Password', 'EWD_FEUP') . ": </label>";
        if (isset($_POST['Confirm_User_Password'])) {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='Confirm_User_Password' value='" . $_POST['Confirm_User_Password'] . "'>";
        } else {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='Confirm_User_Password'>";
        }
        $ReturnString .= "</div>";
        ?>


        <?php 
        $ReturnString .= "<span class='ipad_fix'></span><div class='pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Register_Submit' value='" . "Send" . "'></div>";
        $ReturnString .= "</form>";
        $ReturnString .= '                        <div class="terms_cond">
                            I accept the <a href="/terms-and-conditions" target="_blank">Terms and Conditions</a>
                        </div>';
        $ReturnString .= "</div>";
    } else {
        $ReturnString = "<div class='ewd-feup-email-confirmation'>";
        if ($ConfirmationSuccess == "Yes") {
            $ReturnString .= __("Thanks for confirming your e-mail address!", 'EWD_FEUP');
        }
        if ($ConfirmationSuccess == "No") {
            $ReturnString .= __("The confirmation number provided was incorrect. Please contact the site administrator for assistance.", 'EWD_FEUP');
        }
        $ReturnString .= "</div>";
    }
    wp_enqueue_script('inputmask', "/wp-content/js/inputmask.min.js", "jquery", false, true);
    wp_enqueue_script('jquery_inputmask', "/wp-content/js/jquery.inputmask.min.js", "inputmask", false, true);
    wp_enqueue_script('trynow-script', '/wp-content/js/trynow.js', array('jquery'));
    return $ReturnString;
}
function Insert_Edit_Profile($atts)
{
    // Include the required global variables, and create a few new ones
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_fields_table_name, $ewd_feup_user_table_name, $ewd_feup_user_fields_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Time = time();
    $CheckCookie = CheckLoginCookie();
    $Sql = "SELECT * FROM {$ewd_feup_fields_table_name} WHERE Field_Show_In_Front_End='Yes' ORDER BY Field_Order";
    $Fields = $wpdb->get_results($Sql);
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $UserData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ewd_feup_user_fields_table_name} WHERE User_ID='%d'", $User->User_ID));
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'omit_fields' => '', 'submit_text' => __('Edit Profile', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($CheckCookie['Username'] == "") {
        $ReturnString .= __('You must be logged in to access this page.', 'EWD_FEUP');
        if ($login_page != "") {
            $ReturnString .= "<br />" . __('Please', 'EWD_FEUP') . " <a href='" . $login_page . "'>" . __('login', 'EWD_FEUP') . "</a> " . __('to continue.', 'EWD_FEUP');
        }
        return $ReturnString;
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-profile-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-edit-profile-form' class='pure-form pure-form-aligned' enctype='multipart/form-data'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='edit-profile'>";
    $ReturnString .= "<input type='hidden' name='Omit_Fields' value='" . $omit_fields . "'>";
    $Omitted_Fields = explode(",", $omit_fields);
    foreach ($Fields as $Field) {
        if (!in_array($Field->Field_Name, $Omitted_Fields)) {
            if ($Field->Field_Required == "Yes") {
                $Req_Text = "required";
            } else {
                $Req_Text = "";
            }
            $Value = "";
            foreach ($UserData as $UserField) {
                if ($Field->Field_Name == $UserField->Field_Name) {
                    $Value = $UserField->Field_Value;
                }
            }
            $ReturnString .= "<div class='pure-control-group'>";
            $ReturnString .= "<label for='" . $Field->Field_Name . "' id='ewd-feup-edit-" . $Field->Field_ID . "' class='ewd-feup-field-label'>" . __($Field->Field_Name, 'EWD_FEUP') . ": </label>";
            if ($Field->Field_Type == "text" or $Field->Field_Type == "mediumint") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input pure-input-1-3' type='text' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "date") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input pure-input-1-3' type='date' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "datetime") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-datetime-input pure-input-1-3' type='datetime-local' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "textarea") {
                $ReturnString .= "<textarea name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-textarea pure-input-1-2' " . $Req_Text . ">" . $Value . "</textarea>";
            } elseif ($Field->Field_Type == "file") {
                $ReturnString .= __("Current file:", 'EWD_FEUP') . " " . substr($Value, 10) . " | ";
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input pure-input-1-3' type='file' value='' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "select") {
                $Options = explode(",", $Field->Field_Options);
                $ReturnString .= "<select name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-select pure-input-1-3'>";
                foreach ($Options as $Option) {
                    $ReturnString .= "<option value='" . $Option . "' ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "selected='selected'";
                    }
                    $ReturnString .= ">" . $Option . "</option>";
                }
                $ReturnString .= "</select>";
            } elseif ($Field->Field_Type == "radio") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='radio' name='" . $Field->Field_Name . "' value='" . $Option . "' class='ewd-feup-radio' " . $Req_Text . " ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option;
                    $Counter++;
                }
            } elseif ($Field->Field_Type == "checkbox") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                $Values = explode(",", $Value);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='checkbox' name='" . $Field->Field_Name . "[]' value='" . $Option . "' class='ewd-feup-checkbox' " . $Req_Text . " ";
                    if (in_array($Option, $Values)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option . "</br>";
                    $Counter++;
                }
            }
            $ReturnString .= "</div>";
            unset($Req_Text);
        }
    }
    $ReturnString .= "<div class='pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Edit_Profile_Submit' value='" . $submit_text . "'></div>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    return $ReturnString;
}
function Insert_Edit_Times($atts)
{
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_user_table_name;
    global $ewd_feup_fields_table_name, $ewd_feup_user_table_name, $ewd_feup_user_fields_table_name;
    global $login_page, $redirect_page, $Time, $Salt;
    /** @var string $login_page
         * @var string $Time
         * @var string $Salt
         * @var string $omit_fields
    */
    $Omitted_Fields = explode(",", $omit_fields);
    $CheckCookie = CheckLoginCookie();
    $Sql = "SELECT * FROM {$ewd_feup_fields_table_name} WHERE Field_Show_In_Front_End='Yes' ORDER BY `FIELD_ORDER` ASC";
    $Fields = $wpdb->get_results($Sql);
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $UserData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ewd_feup_user_fields_table_name} WHERE User_ID='%d'", $User->User_ID));
    $print_field = function ($Field, $hidden = false) use($Omitted_Fields, $UserData, &$ReturnString) {
        $display_label = $Field->Field_Name;
        if ($display_label == "Breakfast") {
            $display_label = "Reminder 1";
        }
        if ($display_label == "Select your time zone") {
            $display_label = "Time Zone";
        }
        if (!in_array($Field->Field_Name, $Omitted_Fields)) {
            if ($Field->Field_Required == "Yes") {
                $Req_Text = "required";
            }
            $Value = "";
            if ($Field->Field_Name == "Phone") {
                $Field->Field_Type = "tel";
            }
            foreach ($UserData as $UserField) {
                if ($Field->Field_Name == $UserField->Field_Name) {
                    $Value = $UserField->Field_Value;
                }
            }
            if ($Field->Field_Name == "I need the most help...") {
                //                $ReturnString .= '<hr/>';
            }
            $ReturnString .= "<div class='pure-control-group " . ($hidden ? "hidden" : "") . "'>";
            $ReturnString .= "<label for='" . $Field->Field_Name . "' id='ewd-feup-edit-" . $Field->Field_ID . "' class='ewd-feup-field-label'>" . __($display_label, 'EWD_FEUP') . ": </label>";
            if ($Field->Field_Type == "text" or $Field->Field_Type == "mediumint") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input  ' type='text' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "tel") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input  ' type='tel' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "date") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input  ' type='date' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "datetime") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-datetime-input  ' type='datetime-local' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "textarea") {
                $ReturnString .= "<textarea name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-textarea ' " . $Req_Text . ">" . $Value . "</textarea>";
            } elseif ($Field->Field_Type == "file") {
                $ReturnString .= __("Current file:", 'EWD_FEUP') . " " . substr($Value, 10) . " | ";
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input  ' type='file' value='' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "select") {
                $Options = explode(",", $Field->Field_Options);
                $bkend_calculated_time = '';
                if (empty($Value)) {
                    switch ($Field->Field_Name) {
                        case 'Breakfast':
                            $Value = '06:00pm';
                            break;
                        case 'Lunch':
                            $Value = 'None set';
                            break;
                        case 'Dinner':
                            $Value = 'None set';
                            break;
                        default:
                            break;
                    }
                }
                $ReturnString .= "<select rel='" . $bkend_calculated_time . "' name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-select '>";
                foreach ($Options as $Option) {
                    $ReturnString .= "<option value='" . $Option . "' ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "selected='selected'";
                    }
                    $ReturnString .= ">" . $Option . "</option>";
                }
                $ReturnString .= "</select>";
            } elseif ($Field->Field_Type == "radio") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top  " . ($hidden ? "hidden" : "") . "'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='radio' name='" . $Field->Field_Name . "' value='" . $Option . "' class='ewd-feup-radio' " . $Req_Text . " ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option;
                    $Counter++;
                }
            } elseif ($Field->Field_Type == "checkbox") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                $Values = explode(",", $Value);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top  " . ($hidden ? "hidden" : "") . "'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='checkbox' name='" . $Field->Field_Name . "[]' value='" . $Option . "' class='ewd-feup-checkbox' " . $Req_Text . " ";
                    if (in_array($Option, $Values)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option . "</br>";
                    $Counter++;
                }
            }
            $ReturnString .= "</div>";
            unset($Req_Text);
            if ($Field->Field_Name == "I need the most help...") {
                //                $ReturnString .= '<hr/>';
            }
        }
    };
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $CheckCookie = CheckLoginCookie();
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'submit_text' => __('Update Account', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($CheckCookie['Username'] == "") {
        $ReturnString .= __('You must be logged in to access this page.', 'EWD_FEUP');
        if ($login_page != "") {
            $ReturnString .= "<br />" . __('Please', 'EWD_FEUP') . " <a href='" . $login_page . "'>" . __('login', 'EWD_FEUP') . "</a> " . __('to continue.', 'EWD_FEUP');
        }
        return $ReturnString;
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-profile-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form novalidate action='#' method='post' id='ewd-feup-edit-profile-form' class='pure-form pure-form-aligned' enctype='multipart/form-data'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='edit_reminder_times'>";
    //UserData: 0: Time zone; 1: OK to receive texts?; 2: Dinner; 3: Lunch; 4: Breakfast; 5: Phone; 6:Gender; 7: Last Name; 8 First Name: ; 9: I need the most help...; 10: Membership Expiry Date
    //Fields: 5: First Name; 0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    //    $times = array($UserData[4]->Field_Value, $UserData[3]->Field_Value, $UserData[2]->Field_Value);
    $ReturnString .= '<div><br/></div>';
    $ReturnString .= $print_field($Fields[0]);
    $ReturnString .= $print_field($Fields[1]);
    $ReturnString .= $print_field($Fields[2]);
    $ReturnString .= $print_field($Fields[3], true);
    $ReturnString .= $print_field($Fields[4], true);
    $ReturnString .= $print_field($Fields[5], true);
    $ReturnString .= $print_field($Fields[6], true);
    $ReturnString .= $print_field($Fields[7], true);
    $ReturnString .= $print_field($Fields[8], true);
    $ReturnString .= $print_field($Fields[9], true);
    $ReturnString .= $print_field($Fields[10], true);
    $ReturnString .= <<<HTML
<div><br/></div>
<div class="pure-control-group center">
    <select rel="" name="Time zone" id="ewd-feup-register-input-14" class="ewd-feup-select">
    <option value="Please select">Please select</option><option value="PST" selected="selected">Pacific Time Zone</option>
    <option value="EST">Eastern Standard Timezone</option><option value="CST">Central Standard Timezone</option><option value="MST">Mountain Standard Timezone</option></select>
</div>
HTML;
    /** @var string $submit_text */
    $ReturnString .= "<input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Edit_Profile_Submit' value='Save'>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    return $ReturnString;
}
function Insert_Edit_Profile($atts)
{
    /** @var string $redirect_page
     * @var string $login_page
     * @var string $Time
     * @var string $Salt
     * @var string $omit_fields
     */
    // Include the required global variables, and create a few new ones
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_fields_table_name, $ewd_feup_user_table_name, $ewd_feup_user_fields_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $CheckCookie = CheckLoginCookie();
    $Sql = "SELECT * FROM {$ewd_feup_fields_table_name} WHERE Field_Show_In_Front_End='Yes' ORDER BY `FIELD_ORDER` ASC";
    $Fields = $wpdb->get_results($Sql);
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $UserData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ewd_feup_user_fields_table_name} WHERE User_ID='%d'", $User->User_ID));
    //If user doesn't have First name last name, send to first-time-sign-in
    $first_name = array_pop(array_filter($UserData, function ($v) {
        return $v->Field_Name == "First Name";
    }));
    $last_name = array_pop(array_filter($UserData, function ($v) {
        return $v->Field_Name == "Last Name";
    }));
    if (is_object($first_name) && empty($first_name->Field_Value) && is_object($last_name) && empty($last_name->Field_Value)) {
        FEUPRedirect('/first-time-sign-in');
    }
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'omit_fields' => '', 'submit_text' => __('Save settings', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($CheckCookie['Username'] == "") {
        $ReturnString .= __('You must be logged in to access this page.', 'EWD_FEUP');
        if ($login_page != "") {
            $ReturnString .= "<br />" . __('Please', 'EWD_FEUP') . " <a href='" . $login_page . "'>" . __('login', 'EWD_FEUP') . "</a> " . __('to continue.', 'EWD_FEUP');
            if (isset($_SESSION['user_name_changed']) && isset($_SESSION['message_count']) && !empty($_SESSION['user_name_changed']) && $_SESSION['message_count'] > 0) {
                $ReturnString .= "<p class='text-success'>Your email has been changed. Please use your new email for logging in.</p><br/>";
                $_SESSION['message_count']--;
            }
        }
        return $ReturnString;
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-profile-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= "<div class='updated'><p>" . $user_message['Message'] . "</p></div>";
    }
    session_start();
    if (isset($_SESSION['first_sms_sent_to']) && !empty($_SESSION['first_sms_sent_to']) && isset($_SESSION['message_count']) && $_SESSION['message_count'] > 0) {
        $ReturnString .= "<br/><p class='text-success'>Welcome to ThinkThinly. A message has been sent to your number " . $_SESSION['first_sms_sent_to'] . "</p>";
        $_SESSION['message_count']--;
    }
    session_start();
    if (isset($_SESSION['user_updated'])) {
        $ReturnString .= "<br/><p class='updated'>" . $_SESSION['user_updated'] . "</p>";
        unset($_SESSION['user_updated']);
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-edit-profile-form' class='pure-form pure-form-aligned' enctype='multipart/form-data'>";
    //fields
    //5: First Name; 0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='edit_your_settings'>";
    $ReturnString .= "<input type='hidden' name='Omit_Fields' value='" . $omit_fields . "'>";
    $Omitted_Fields = explode(",", $omit_fields);
    //Brian added. Force new username and password if user has just signed up
    $username = $User->Username;
    $user_email = $User->user_email;
    if (strpos($username, "@foobar.com") != false) {
        $username = "";
    }
    $ReturnString .= '<div class="pure-control-group hidden">';
    $ReturnString .= '<label for="Username">Phone number: </label>';
    $ReturnString .= '<input type="text" class="ewd-feup-text-input" name="Username" value="' . $username . '" required>';
    $ReturnString .= '</div>';
    if (empty($username)) {
        $ReturnString .= '<div class="pure-control-group">';
        $ReturnString .= '<label for ="User_Password">Password: </label>';
        $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "User_Password" value = "" required>';
        $ReturnString .= '</div>';
        $ReturnString .= '<div class="pure-control-group">';
        $ReturnString .= '<label for="Confirm_User_Password" > Repeat Password: </label>';
        $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "Confirm_User_Password" value = "" >';
        $ReturnString .= '</div>';
    }
    ////Brian added force new username
    $print_field = function ($Field) use($Omitted_Fields, $UserData, &$ReturnString) {
        $display_label = $Field->Field_Name;
        if ($display_label == "Breakfast") {
            $display_label = "Reminder time";
        }
        if ($display_label == "Lunch") {
            $display_label = "Reminder 2";
        }
        if ($display_label == "Dinner") {
            $display_label = "Reminder 3";
        }
        if ($display_label == "Select your time zone") {
            $display_label = "Time zone";
        }
        if (!in_array($Field->Field_Name, $Omitted_Fields)) {
            if ($Field->Field_Required == "Yes") {
                $Req_Text = "required";
            }
            $Value = "";
            if ($Field->Field_Name == "Phone") {
                $Field->Field_Type = "tel";
            }
            foreach ($UserData as $UserField) {
                if ($Field->Field_Name == $UserField->Field_Name) {
                    $Value = $UserField->Field_Value;
                }
            }
            if ($Field->Field_Name == "I need the most help...") {
                $ReturnString .= '<hr/>';
            }
            $ReturnString .= "<div class='pure-control-group row-id-" . $Field->Field_ID . "'>";
            $ReturnString .= "<label for='" . $Field->Field_Name . "' id='ewd-feup-edit-. {$Field->Field_IDclass}='ewd-feup-field-label'>" . __($display_label, 'EWD_FEUP') . "</label>";
            if ($Field->Field_Type == "text" or $Field->Field_Type == "mediumint") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input pure-input-1-3' type='text' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "tel") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input pure-input-1-3' type='tel' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "date") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input pure-input-1-3' type='date' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "datetime") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-datetime-input pure-input-1-3' type='datetime-local' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "textarea") {
                $ReturnString .= "<textarea name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-textarea pure-input-1-2' " . $Req_Text . ">" . $Value . "</textarea>";
            } elseif ($Field->Field_Type == "file") {
                $ReturnString .= __("Current file:", 'EWD_FEUP') . " " . substr($Value, 10) . " | ";
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input pure-input-1-3' type='file' value='' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "select") {
                $Options = explode(",", $Field->Field_Options);
                $bkend_calculated_time = '';
                if (empty($Value)) {
                    switch ($Field->Field_Name) {
                        case 'Breakfast':
                            $Value = '12:00pm';
                            break;
                        case 'Lunch':
                            $Value = 'None set';
                            break;
                        case 'Dinner':
                            $Value = 'None set';
                            break;
                        default:
                            break;
                    }
                }
                $ReturnString .= "<select rel='" . $bkend_calculated_time . "' name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-select pure-input-1-3'>";
                foreach ($Options as $Option) {
                    $ReturnString .= "<option value='" . $Option . "' ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "selected='selected'";
                    }
                    $ReturnString .= ">" . $Option . "</option>";
                }
                $ReturnString .= "</select>";
            } elseif ($Field->Field_Type == "radio") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='radio' name='" . $Field->Field_Name . "' value='" . $Option . "' class='ewd-feup-radio' " . $Req_Text . " ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option;
                    $Counter++;
                }
            } elseif ($Field->Field_Type == "checkbox") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                $Values = explode(",", $Value);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='checkbox' name='" . $Field->Field_Name . "[]' value='" . $Option . "' class='ewd-feup-checkbox' " . $Req_Text . " ";
                    if (in_array($Option, $Values)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option . "</br>";
                    $Counter++;
                }
            }
            $ReturnString .= "</div>";
            unset($Req_Text);
            if ($Field->Field_Name == "I need the most help...") {
                $ReturnString .= '<hr/>';
            }
        }
    };
    //5: First Name; 0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    $ReturnString .= '<div id="your_settings">';
    $ReturnString .= '
    <div class="text_with_hr">
    <span>
        Reminder times &nbsp;&nbsp;
    </span>
</div>';
    $ReturnString .= $print_field($Fields[0]);
    $ReturnString .= $print_field($Fields[1]);
    $ReturnString .= $print_field($Fields[2]);
    $ReturnString .= $print_field($Fields[4]);
    $ReturnString .= '<input type="submit" class="ewd-feup-submit pure-button pure-button-primary" name="Edit_Profile_Submit" value="Save">';
    $ReturnString .= '<div class="break big"></div>
    <div class="text_with_hr">
    <span>
        Your info &nbsp;&nbsp;
    </span>
</div>
  <div class="break big"></div>';
    $ReturnString .= <<<HTML
        <div class="pure-control-group"><label for="Phone" class="ewd-feup-field-label">Phone: </label>
<input name="Phone" disabled class="ewd-feup-select pure-input-1-3" value="{$username}">
</div>
HTML;
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for="user_email">Email: </label>';
    $ReturnString .= '<input type="email" class="ewd-feup-text-input pure-input-1-3" name="user_email" value="' . $user_email . '" >';
    $ReturnString .= '</div>';
    $ReturnString .= $print_field($Fields[5]);
    $ReturnString .= $print_field($Fields[6]);
    $ReturnString .= '<input type="submit" class="ewd-feup-submit pure-button pure-button-primary" name="Edit_Profile_Submit" value="Save">';
    $ReturnString .= '<div class="break big"></div>
    <div class="text_with_hr">
    <span>
        Password &nbsp;&nbsp;
    </span>
</div>
  <div class="break big"></div>';
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for ="User_Password">New password</label>';
    $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "User_Password" value = "" >';
    $ReturnString .= '</div>';
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for="Confirm_User_Password"> Retype password</label>';
    $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "Confirm_User_Password" value = "" >';
    $ReturnString .= '</div>';
    //brian3t extract $FIELDS here
    //insert form for paypal
    $userdata_ = array();
    foreach ($UserData as $user_data) {
        $user_data_[$user_data->Field_Name] = $user_data;
    }
    $expiry_date = $user_data_["Membership Expiry Date"]->Field_Value;
    $output = "";
    $output .= "<script> var \$user_id= {$User->User_ID} ; </script>";
    $ReturnString .= $output;
    ////brian3t extract form field add paypal
    /** @var string $submit_text */
    $ReturnString .= '<input type="submit" class="ewd-feup-submit pure-button pure-button-primary" name="Edit_Profile_Submit" value="Save">';
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    wp_enqueue_script('inputmask', "/wp-content/js/inputmask.min.js", "jquery", false, true);
    wp_enqueue_script('jquery_inputmask', "/wp-content/js/jquery.inputmask.min.js", "inputmask", false, true);
    wp_enqueue_script('your_settings', '/wp-content/js/your_settings.js', array('jquery'));
    wp_enqueue_script('timezone', "/wp-content/js/jstz-1.0.4.min.js", "jquery", false, true);
    return $ReturnString;
}
function Insert_Edit_Profile($atts)
{
    /** @var string $redirect_page
     * @var string $login_page
     * @var string $Time
     * @var string $Salt
     * @var string $omit_fields
     */
    // Include the required global variables, and create a few new ones
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_fields_table_name, $ewd_feup_user_table_name, $ewd_feup_user_fields_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $CheckCookie = CheckLoginCookie();
    $Sql = "SELECT * FROM {$ewd_feup_fields_table_name} WHERE Field_Show_In_Front_End='Yes' ORDER BY `FIELD_ORDER` ASC";
    $Fields = $wpdb->get_results($Sql);
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $UserData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ewd_feup_user_fields_table_name} WHERE User_ID='%d'", $User->User_ID));
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'omit_fields' => '', 'submit_text' => __('Save settings', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    if ($CheckCookie['Username'] == "") {
        $ReturnString .= __('You must be logged in to access this page.', 'EWD_FEUP');
        if ($login_page != "") {
            $ReturnString .= "<br />" . __('Please', 'EWD_FEUP') . " <a href='" . $login_page . "'>" . __('login', 'EWD_FEUP') . "</a> " . __('to continue.', 'EWD_FEUP');
            if (isset($_SESSION['user_name_changed']) && isset($_SESSION['message_count']) && !empty($_SESSION['user_name_changed']) && $_SESSION['message_count'] > 0) {
                $ReturnString .= "<p class='text-success'>Your email has been changed. Please use your new email for logging in.</p><br/>";
                $_SESSION['message_count']--;
            }
        }
        return $ReturnString;
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-profile-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= "<div class='updated'><p>" . $user_message['Message'] . "</p></div>";
    }
    session_start();
    if (isset($_SESSION['first_sms_sent_to']) && !empty($_SESSION['first_sms_sent_to']) && isset($_SESSION['message_count']) && $_SESSION['message_count'] > 0) {
        $ReturnString .= "<br/><p class='text-success'>Welcome to ThinkThinly. A message has been sent to your number " . $_SESSION['first_sms_sent_to'] . "</p>";
        $_SESSION['message_count']--;
    }
    session_start();
    if (isset($_SESSION['user_updated'])) {
        $ReturnString .= "<br/><p class='updated'>" . $_SESSION['user_updated'] . "</p>";
        unset($_SESSION['user_updated']);
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-edit-profile-form' class='pure-form pure-form-aligned' enctype='multipart/form-data'>";
    //fields
    //5: First Name; 0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='edit-profile'>";
    $ReturnString .= "<input type='hidden' name='Omit_Fields' value='" . $omit_fields . "'>";
    $Omitted_Fields = explode(",", $omit_fields);
    //Brian added. Force new username and password if user has just signed up
    $username = $User->Username;
    $user_email = $User->user_email;
    if (strpos($username, "@foobar.com") != false) {
        $username = "";
    }
    $ReturnString .= '<div class="pure-control-group hidden">';
    $ReturnString .= '<label for="Username">Phone number: </label>';
    $ReturnString .= '<input type="text" class="ewd-feup-text-input" name="Username" value="' . $username . '" required>';
    $ReturnString .= '</div>';
    if (empty($username)) {
        $ReturnString .= '<div class="pure-control-group">';
        $ReturnString .= '<label for ="User_Password">Password: </label>';
        $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "User_Password" value = "" required>';
        $ReturnString .= '</div>';
        $ReturnString .= '<div class="pure-control-group">';
        $ReturnString .= '<label for="Confirm_User_Password" > Repeat Password: </label>';
        $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "Confirm_User_Password" value = "" >';
        $ReturnString .= '</div>';
    }
    ////Brian added force new username
    //fixing data before display
    //5: First Name; 0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    $print_field = function ($Field) use($Omitted_Fields, $UserData, &$ReturnString) {
        $display_label = $Field->Field_Name;
        if ($display_label == "Breakfast") {
            $display_label = "Time 1";
        }
        if ($display_label == "Lunch") {
            $display_label = "Time 2";
        }
        if ($display_label == "Dinner") {
            $display_label = "Time 3";
        }
        if ($display_label == "Select your time zone") {
            $display_label = "Time Zone";
        }
        if (!in_array($Field->Field_Name, $Omitted_Fields)) {
            if ($Field->Field_Required == "Yes") {
                $Req_Text = "required";
            }
            $Value = "";
            if ($Field->Field_Name == "Phone") {
                $Field->Field_Type = "tel";
            }
            foreach ($UserData as $UserField) {
                if ($Field->Field_Name == $UserField->Field_Name) {
                    $Value = $UserField->Field_Value;
                }
            }
            if ($Field->Field_Name == "I need the most help...") {
                $ReturnString .= '<hr/>';
            }
            $ReturnString .= "<div class='pure-control-group'>";
            $ReturnString .= "<label for='" . $Field->Field_Name . "' id='ewd-feup-edit-" . $Field->Field_ID . "' class='ewd-feup-field-label'>" . __($display_label, 'EWD_FEUP') . ": </label>";
            if ($Field->Field_Type == "text" or $Field->Field_Type == "mediumint") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input pure-input-1-3' type='text' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "tel") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input pure-input-1-3' type='tel' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "date") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input pure-input-1-3' type='date' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "datetime") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-datetime-input pure-input-1-3' type='datetime-local' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "textarea") {
                $ReturnString .= "<textarea name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-textarea pure-input-1-2' " . $Req_Text . ">" . $Value . "</textarea>";
            } elseif ($Field->Field_Type == "file") {
                $ReturnString .= __("Current file:", 'EWD_FEUP') . " " . substr($Value, 10) . " | ";
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input pure-input-1-3' type='file' value='' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "select") {
                $Options = explode(",", $Field->Field_Options);
                $bkend_calculated_time = '';
                if (empty($Value)) {
                    switch ($Field->Field_Name) {
                        case 'Breakfast':
                            $Value = '12:00pm';
                            break;
                        case 'Lunch':
                            $Value = 'None set';
                            break;
                        case 'Dinner':
                            $Value = 'None set';
                            break;
                        default:
                            break;
                    }
                }
                $ReturnString .= "<select rel='" . $bkend_calculated_time . "' name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-select pure-input-1-3'>";
                foreach ($Options as $Option) {
                    $ReturnString .= "<option value='" . $Option . "' ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "selected='selected'";
                    }
                    $ReturnString .= ">" . $Option . "</option>";
                }
                $ReturnString .= "</select>";
            } elseif ($Field->Field_Type == "radio") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='radio' name='" . $Field->Field_Name . "' value='" . $Option . "' class='ewd-feup-radio' " . $Req_Text . " ";
                    if (trim($Option) == trim($Value)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option;
                    $Counter++;
                }
            } elseif ($Field->Field_Type == "checkbox") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                $Values = explode(",", $Value);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='pure-control-group ewd-feup-negative-top'><label class='pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='checkbox' name='" . $Field->Field_Name . "[]' value='" . $Option . "' class='ewd-feup-checkbox' " . $Req_Text . " ";
                    if (in_array($Option, $Values)) {
                        $ReturnString .= "checked";
                    }
                    $ReturnString .= ">" . $Option . "</br>";
                    $Counter++;
                }
            }
            $ReturnString .= "</div>";
            unset($Req_Text);
            if ($Field->Field_Name == "I need the most help...") {
                $ReturnString .= '<hr/>';
            }
        }
    };
    //5: First Name; 0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    $ReturnString .= '<div id="your_settings">
    <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
        <li class="active"><a href="#tab_one" data-toggle="tab">Account</a></li>
        <li><a href="#tab_two" data-toggle="tab">Reminder times</a></li>
        <li ' . ($User->subscription == "active" ? ' class="hidden" ' : '') . '><a href="#tab_three" data-toggle="tab">Subscription</a></li>
        <li><a href="#tab_four" data-toggle="tab">Summary</a></li>
    </ul>
    <div id="my-tab-content" class="tab-content">
        <div class="tab-pane active" id="tab_one">';
    $ReturnString .= $print_field($Fields[5]);
    $ReturnString .= $print_field($Fields[6]);
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for="user_email">Email: </label>';
    $ReturnString .= '<input type="email" class="ewd-feup-text-input pure-input-1-3" name="user_email" value="' . $user_email . '" >';
    $ReturnString .= '</div>';
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for ="User_Password">Set new password (leave this field empty if you don\'t want to change your password): </label>';
    $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "User_Password" value = "" >';
    $ReturnString .= '</div>';
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for="Confirm_User_Password" > Repeat Password: </label>';
    $ReturnString .= '<input type = "password" class="ewd-feup-text-input" name = "Confirm_User_Password" value = "" >';
    $ReturnString .= '</div>';
    $ReturnString .= '
        </div>
        <div class="tab-pane" id="tab_two">
            Tell us what times you need motivational boost and we\'ll text you then.
            <br/>Pick up to three times.  (Hint: You can choose meal times, workout times, late afternoon cravings or any time you need encouragement.)';
    $ReturnString .= $print_field($Fields[0]);
    $ReturnString .= $print_field($Fields[1]);
    $ReturnString .= $print_field($Fields[2]);
    $ReturnString .= $print_field($Fields[4]);
    $ReturnString .= '
        </div>
        <div class="tab-pane" id="tab_three">
            <h3>Lasting change starts here.</h3>
Get motivational texts every day up to three times a day daily for just $4.99 a month.<br/>
That\'s the cost of one cup of coffee.
                              Cancel any time.<br/>
                              <br/>
                              <button id="add_membership" type="button"> Yes, please send me messages! </button>
        </div>
        <div class="tab-pane" id="tab_four">
            <h3>You did it!</h3>
            The new you is on its way, one motivational message at a time.
            <h4>Settings</h4>
            ';
    $ReturnString .= $print_field($Fields[0]);
    $ReturnString .= $print_field($Fields[1]);
    $ReturnString .= $print_field($Fields[2]);
    $ReturnString .= $print_field($Fields[4]);
    $ReturnString .= '<div class="pure-control-group">';
    $ReturnString .= '<label for="Username">Phone number: </label>';
    $ReturnString .= '<input type="text" disabled="disabled" class="ewd-feup-text-input" name="Username" value="' . $username . '" required>';
    $ReturnString .= '</div>';
    $ReturnString .= '</div>        ';
    //    print_field($Field, $Omitted_Fields, $UserData, $ReturnString);
    //brian3t extract $FIELDS here
    //insert form for paypal
    $userdata_ = array();
    foreach ($UserData as $user_data) {
        $user_data_[$user_data->Field_Name] = $user_data;
    }
    $expiry_date = $user_data_["Membership Expiry Date"]->Field_Value;
    $output = "";
    //    $output      = '<hr/>';
    //    $output .= <<<HTML
    //    <div class="pure-control-group"><label for="Membership Expiry Date" id="ewd-feup-edit-16" class="ewd-feup-field-label">Expires:
    //        </label><span class="form_text">$expiry_date
    //        </span><input name="Membership Expiry Date" value="$expiry_date" id="ewd-feup-register-input-16" type="hidden">
    //        <label>
    //        </label><span class="form_text">Extend membership by <input name="qty" size=1 value=1> months
    //        </span>
    //        <label>
    //        </label><button type="button" id="add_membership">Go</button>
    //
    //    </div>
    //HTML;
    //    $output .= '<hr/>';
    $output .= "<script> var \$user_id= {$User->User_ID} ; </script>";
    $ReturnString .= $output;
    ////brian3t extract form field add paypal
    /** @var string $submit_text */
    $ReturnString .= "<div class='pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Edit_Profile_Submit' value='" . $submit_text . "'></div>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    wp_enqueue_script('inputmask', "/wp-content/js/inputmask.min.js", "jquery", false, true);
    wp_enqueue_script('jquery_inputmask', "/wp-content/js/jquery.inputmask.min.js", "inputmask", false, true);
    wp_enqueue_script('your_settings', '/wp-content/js/your_settings.js', array('jquery'));
    wp_enqueue_script('timezone', "/wp-content/js/jstz-1.0.4.min.js", "jquery", false, true);
    $ReturnString .= '    </div>
</div>';
    //determine tab
    $tab = 2;
    //0: Breakfast; 1: Lunch; 2: Dinner; 3: I need the most help...; 4: Select your time zone; 5: First Name; 6:Last Name; 7: Gender; 8: OK to receive texts?; 9: Phone;
    if (empty($UserData[10]->Field_Value)) {
        $tab = 1;
    }
    if ($User->subscription == "active") {
        $tab = 4;
    }
    if (!empty($UserData[0]->Field_Value)) {
        if (strtotime($UserData[0]->Field_Value) < time()) {
            $tab = 3;
        }
    }
    $ReturnString .= "<script>var \$tab = '{$tab}';</script>";
    return $ReturnString;
}
function Insert_Edit_Account_Form($atts)
{
    global $wpdb, $user_message, $feup_success;
    global $ewd_feup_user_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $CheckCookie = CheckLoginCookie();
    //$Sql = "SELECT * FROM $ewd_feup_fields_table_name ";
    //$Fields = $wpdb->get_results($Sql);
    $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
    $feup_Label_Please = get_option("EWD_FEUP_Label_Please");
    if ($feup_Label_Please == "") {
        $feup_Label_Please = __("Please", 'EWD_FEUP');
    }
    $feup_Label_To_Continue = get_option("EWD_FEUP_Label_To_Continue");
    if ($feup_Label_To_Continue == "") {
        $feup_Label_To_Continue = __("To Continue", 'EWD_FEUP');
    }
    $feup_Label_Login = get_option("EWD_FEUP_Label_Login");
    if ($feup_Label_Login == "") {
        $feup_Label_Login = __("Login", 'EWD_FEUP');
    }
    $feup_Label_Email = get_option("EWD_FEUP_Label_Email");
    if ($feup_Label_Email == "") {
        $feup_Label_Email = __("Email", 'EWD_FEUP');
    }
    $feup_Label_Username = get_option("EWD_FEUP_Label_Username");
    if ($feup_Label_Username == "") {
        $feup_Label_Username = __("Username", 'EWD_FEUP');
    }
    $feup_Label_Password = get_option("EWD_FEUP_Label_Password");
    if ($feup_Label_Password == "") {
        $feup_Label_Password = __("Password", 'EWD_FEUP');
    }
    $feup_Label_Repeat_Password = get_option("EWD_FEUP_Label_Repeat_Password");
    if ($feup_Label_Repeat_Password == "") {
        $feup_Label_Repeat_Password = __("Repeat Password", 'EWD_FEUP');
    }
    $feup_Label_Password_Strength = get_option("EWD_FEUP_Label_Password_Strength");
    if ($feup_Label_Password_Strength == "") {
        $feup_Label_Password_Strength = __("Password Strength", 'EWD_FEUP');
    }
    $feup_Label_Require_Login_Message = get_option("EWD_FEUP_Label_Require_Login_Message");
    if ($feup_Label_Require_Login_Message == "") {
        $feup_Label_Require_Login_Message = __('You must be logged in to access this page.', 'EWD_FEUP');
    }
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'login_page' => '', 'submit_text' => __('Update Account', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= EWD_FEUP_Add_Modified_Styles();
    if ($CheckCookie['Username'] == "") {
        $ReturnString .= $feup_Label_Require_Login_Message;
        if ($login_page != "") {
            $ReturnString .= "<br />" . $feup_Label_Please . " <a href='" . $login_page . "'>" . $feup_Label_Login . "</a> " . $feup_Label_To_Continue;
        }
        return $ReturnString;
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-edit-account-form-div' class='ewd-feup-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-edit-account-form' class='pure-form pure-form-aligned feup-pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='edit-account'>";
    if ($Username_Is_Email == "Yes") {
        $ReturnString .= "<div class='feup-pure-control-group'>";
        $ReturnString .= "<label for='Username' id='ewd-feup-register-username-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Email . ": </label>";
        // $ReturnString .= "<div id='ewd-feup-register-username-div' class='ewd-feup-field-label'>" . __('Email', 'EWD_FEUP') . ": </div>";
        $ReturnString .= "<input type='email' class='ewd-feup-text-input' name='Username' value='" . $User->Username . "'>";
        $ReturnString .= "</div>";
    } else {
        $ReturnString .= "<div class='feup-pure-control-group'>";
        $ReturnString .= "<label for='Username' id='ewd-feup-register-username-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Username . ": </label>";
        // $ReturnString .= "<div id='ewd-feup-register-username-div' class='ewd-feup-field-label'>" . __('Username', 'EWD_FEUP') . ": </div>";
        $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' value='" . $User->Username . "'>";
        $ReturnString .= "</div>";
    }
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Password' id='ewd-feup-login-password-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Password . ": </label>";
    // $ReturnString .= "<div id='ewd-feup-register-password-div' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . ": </div>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input ewd-feup-password-input' name='User_Password' value=''>";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Repeat-Password' id='ewd-feup-register-password-confirm-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Repeat_Password . ": </label>";
    // $ReturnString .= "<div id='ewd-feup-register-password-confirm-div' class='ewd-feup-field-label'>" . __('Repeat Password', 'EWD_FEUP') . ": </div>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input ewd-feup-check-password-input' name='Confirm_User_Password' value=''>";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Password Strength' id='ewd-feup-password-strength' class='ewd-feup-field-label'>" . $feup_Label_Password_Strength . ": </label>";
    $ReturnString .= "<span id='ewd-feup-password-result'>Too Short</span>";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit feup-pure-button feup-pure-button-primary' name='Edit_Profile_Submit' value='" . $submit_text . "'></div>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    return $ReturnString;
}
function Insert_Register_Form($atts)
{
    // Include the required global variables, and create a few new ones
    global $wpdb, $post, $user_message, $feup_success;
    global $ewd_feup_fields_table_name;
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $Use_Captcha = get_option("EWD_FEUP_Use_Captcha");
    $Time = time();
    $Sql = "SELECT * FROM {$ewd_feup_fields_table_name} ORDER BY Field_Order";
    $Fields = $wpdb->get_results($Sql);
    $ReturnString = "";
    if (isset($_GET['ConfirmEmail'])) {
        ConfirmUserEmail();
    }
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'redirect_field' => "", 'redirect_array_string' => "", 'submit_text' => __('Register', 'EWD_FEUP')), $atts));
    if (isset($_GET['ConfirmEmail'])) {
        $ConfirmationSuccess = ConfirmUserEmail();
    }
    if ($feup_success and $redirect_field != "") {
        $redirect_page = Determine_Redirect_Page($redirect_field, $redirect_array_string, $redirect_page);
    }
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= EWD_FEUP_Add_Modified_Styles();
    if (!isset($ConfirmationSuccess)) {
        $ReturnString .= "<div id='ewd-feup-register-form-div' class='ewd-feup-form-div'>";
        if (isset($user_message['Message'])) {
            $ReturnString .= $user_message['Message'];
        }
        $ReturnString .= "<form action='#' method='post' id='ewd-feup-register-form' class='feup-pure-form feup-pure-form-aligned' enctype='multipart/form-data'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='register'>";
        $ReturnString .= "<input type='hidden' name='ewd-feup-post-id' value='" . $post->ID . "'>";
        $ReturnString .= "<div class='feup-pure-control-group'>";
        if ($Username_Is_Email == "Yes") {
            $ReturnString .= "<label for='Username' id='ewd-feup-register-username-div' class='ewd-feup-field-label'>" . __('Email', 'EWD_FEUP') . ": </label>";
            if (isset($_POST['Username'])) {
                $ReturnString .= "<input type='email' class='ewd-feup-text-input' name='Username' value='" . $_POST['Username'] . "'>";
            } else {
                $ReturnString .= "<input type='email' class='ewd-feup-text-input' name='Username' placeholder='" . __('Email', 'EWD_FEUP') . "...'>";
            }
        } else {
            $ReturnString .= "<label for='Username' id='ewd-feup-register-username-div' class='ewd-feup-field-label'>" . __('Username', 'EWD_FEUP') . ": </label>";
            if (isset($_POST['Username'])) {
                $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' value='" . $_POST['Username'] . "'>";
            } else {
                $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' placeholder='" . __('Username', 'EWD_FEUP') . "...'>";
            }
        }
        $ReturnString .= "</div>";
        $ReturnString .= "<div class='feup-pure-control-group'>";
        $ReturnString .= "<label for='Password' id='ewd-feup-register-password-div' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . ": </label>";
        if (isset($_POST['User_Password'])) {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password' value='" . $_POST['User_Password'] . "'>";
        } else {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password'>";
        }
        $ReturnString .= "</div>";
        $ReturnString .= "<div class='feup-pure-control-group'>";
        $ReturnString .= "<label for='Repeat Password' id='ewd-feup-register-password-confirm-div' class='ewd-feup-field-label'>" . __('Repeat Password', 'EWD_FEUP') . ": </label>";
        if (isset($_POST['Confirm_User_Password'])) {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='Confirm_User_Password' value='" . $_POST['Confirm_User_Password'] . "'>";
        } else {
            $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='Confirm_User_Password'>";
        }
        $ReturnString .= "</div>";
        foreach ($Fields as $Field) {
            if ($Field->Field_Required == "Yes") {
                $Req_Text = "required";
            } else {
                $Req_Text = "";
            }
            $ReturnString .= "<div class='feup-pure-control-group'>";
            $ReturnString .= "<label for='" . $Field->Field_Name . "' id='ewd-feup-register-" . $Field->Field_ID . "' class='ewd-feup-field-label'>" . __($Field->Field_Name, 'EWD_FEUP') . ": </label>";
            if ($Field->Field_Type == "text" or $Field->Field_Type == "mediumint") {
                if (isset($_POST[str_replace(" ", "_", $Field->Field_Name)])) {
                    $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input pure-input-1-3' type='text' value='" . $_POST[str_replace(" ", "_", $Field->Field_Name)] . "' " . $Req_Text . "/>";
                } else {
                    $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-text-input' type='text' placeholder='" . $Field->Field_Name . "' " . $Req_Text . "/>";
                }
            } elseif ($Field->Field_Type == "date") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input' type='date' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "datetime") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-datetime-input' type='datetime-local' value='" . $Value . "' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "file") {
                $ReturnString .= "<input name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-date-input' type='file' value='' " . $Req_Text . "/>";
            } elseif ($Field->Field_Type == "textarea") {
                $ReturnString .= "<textarea name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-textarea' " . $Req_Text . ">" . $_POST[str_replace(" ", "_", $Field->Field_Name)] . "</textarea>";
            } elseif ($Field->Field_Type == "select") {
                $Options = explode(",", $Field->Field_Options);
                $ReturnString .= "<select name='" . $Field->Field_Name . "' id='ewd-feup-register-input-" . $Field->Field_ID . "' class='ewd-feup-select'>";
                foreach ($Options as $Option) {
                    $ReturnString .= "<option value='" . $Option . "' ";
                    if (isset($_POST[str_replace(" ", "_", $Field->Field_Name)]) and $Option == $_POST[str_replace(" ", "_", $Field->Field_Name)]) {
                        $ReturnString .= "selected='selected'";
                    }
                    $ReturnString .= ">" . $Option . "</option>";
                }
                $ReturnString .= "</select>";
            } elseif ($Field->Field_Type == "radio") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='feup-pure-control-group ewd-feup-negative-top'><label class='feup-pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='radio' name='" . $Field->Field_Name . "' value='" . $Option . "' class='ewd-feup-radio' " . $Req_Text . " ";
                    if (isset($_POST[str_replace(" ", "_", $Field->Field_Name)]) and $Option == $_POST[str_replace(" ", "_", $Field->Field_Name)]) {
                        $ReturnString .= "checked='checked'";
                    }
                    $ReturnString .= ">" . $Option . "<br/>";
                    $Counter++;
                }
            } elseif ($Field->Field_Type == "checkbox") {
                $Counter = 0;
                $Options = explode(",", $Field->Field_Options);
                foreach ($Options as $Option) {
                    if ($Counter != 0) {
                        $ReturnString .= "</div><div class='feup-pure-control-group ewd-feup-negative-top'><label class='feup-pure-radio'></label>";
                    }
                    $ReturnString .= "<input type='checkbox' name='" . $Field->Field_Name . "[]' value='" . $Option . "' class='ewd-feup-checkbox' " . $Req_Text . " ";
                    if (isset($_POST[str_replace(" ", "_", $Field->Field_Name)])) {
                        if (in_array($Option, $_POST[str_replace(" ", "_", $Field->Field_Name)])) {
                            $ReturnString .= "checked";
                        }
                    }
                    $ReturnString .= ">" . $Option . "</br>";
                    $Counter++;
                }
            }
            $ReturnString .= "</div>";
            unset($Req_Text);
        }
        if ($Use_Captcha == "Yes") {
            $ReturnString .= EWD_FEUP_Add_Captcha();
        }
        $ReturnString .= "<div class='feup-pure-control-group'><label for='submit'></label><input type='submit' class='ewd-feup-submit feup-pure-button feup-pure-button-primary' name='Register_Submit' value='" . $submit_text . "'></div>";
        $ReturnString .= "</form>";
        $ReturnString .= "</div>";
    } else {
        $ReturnString = "<div class='ewd-feup-email-confirmation'>";
        if ($ConfirmationSuccess == "Yes") {
            $ReturnString .= __("Thanks for confirming your e-mail address!", 'EWD_FEUP');
        }
        if ($ConfirmationSuccess == "No") {
            $ReturnString .= __("The confirmation number provided was incorrect. Please contact the site administrator for assistance.", 'EWD_FEUP');
        }
        $ReturnString .= "</div>";
    }
    return $ReturnString;
}
Beispiel #14
0
function Insert_Login_Form($atts)
{
    global $user_message, $feup_success;
    // Include the required global variables, and create a few new ones
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $Time = time();
    $Payment_Frequency = get_option("EWD_FEUP_Payment_Frequency");
    $Payment_Types = get_option("EWD_FEUP_Payment_Types");
    $Membership_Cost = get_option("EWD_FEUP_Membership_Cost");
    $Levels_Payment_Array = get_option("EWD_FEUP_Levels_Payment_Array");
    $feup_Label_Login = get_option("EWD_FEUP_Label_Login");
    if ($feup_Label_Login == "") {
        $feup_Label_Login = __("Login", 'EWD_FEUP');
    }
    $feup_Label_Email = get_option("EWD_FEUP_Label_Email");
    if ($feup_Label_Email == "") {
        $feup_Label_Email = __("Email", 'EWD_FEUP');
    }
    $feup_Label_Username = get_option("EWD_FEUP_Label_Username");
    if ($feup_Label_Username == "") {
        $feup_Label_Username = __("Username", 'EWD_FEUP');
    }
    $feup_Label_Password = get_option("EWD_FEUP_Label_Password");
    if ($feup_Label_Password == "") {
        $feup_Label_Password = __("Password", 'EWD_FEUP');
    }
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'redirect_field' => '', 'redirect_array_string' => '', 'submit_text' => __('Login', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= EWD_FEUP_Add_Modified_Styles();
    $ReturnString .= "</style>";
    if ($_POST['Payment_Required'] == "Yes") {
        if ($Payment_Types == "Membership" and is_numeric($Membership_Cost) and $Membership_Cost != "" or $Payment_Types == "Levels" and sizeof($Levels_Payment_Array) > 0) {
            $ReturnString .= do_shortcode("[account-payment]");
            return $ReturnString;
        }
    }
    if ($feup_success and $redirect_field != "") {
        $redirect_page = Determine_Redirect_Page($redirect_field, $redirect_array_string, $redirect_page);
    }
    // if there is no redirect page, have the current page reload
    if ($feup_success and $redirect_page != '#') {
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-login' class='ewd-feup-login-form-div' class='ewd-feup-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    if (strpos($user_message['Message'], "Payment required.") !== false) {
        $ReturnString .= "</div>";
        return $ReturnString;
    }
    //Payment required
    $ReturnString .= "<form action='user-blog' method='post' id='ewd-feup-login-form' class='pure-form pure-form-aligned feup-pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='login'>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    if ($Username_Is_Email == "Yes") {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Email . ": </label>";
        $ReturnString .= "<input type='email' class='ewd-feup-text-input ewd-feup-login-field' name='Username' placeholder='" . $feup_Label_Email . "...'>";
    } else {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Username . ": </label>";
        $ReturnString .= "<input type='text' class='ewd-feup-text-input ewd-feup-login-field' name='Username' placeholder='" . $feup_Label_Username . "...'>";
    }
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Password' id='ewd-feup-login-password-div' class='ewd-feup-field-label ewd-feup-login-label'>" . $feup_Label_Password . ": </label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input ewd-feup-login-field' name='User_Password'>";
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='feup-pure-control-group'>";
    $ReturnString .= "<label for='Submit'></label><input type='submit' class='ewd-feup-submit ewd-feup-login-submit feup-pure-button feup-pure-button-primary' name='Login_Submit' value='" . $feup_Label_Login . "'>";
    $ReturnString .= "</div>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    return $ReturnString;
}
function Insert_Login_Form($atts)
{
    global $user_message, $feup_success;
    global $ewd_feup_fields_table_name, $ewd_feup_user_table_name, $ewd_feup_user_fields_table_name, $wpdb;
    // Include the required global variables, and create a few new ones
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $Custom_CSS = get_option("EWD_FEUP_Custom_CSS");
    $Username_Is_Email = get_option("EWD_FEUP_Username_Is_Email");
    $Time = time();
    $ReturnString = "";
    // Get the attributes passed by the shortcode, and store them in new variables for processing
    extract(shortcode_atts(array('redirect_page' => '#', 'redirect_field' => '', 'redirect_array_string' => '', 'submit_text' => __('Login', 'EWD_FEUP')), $atts));
    $ReturnString .= "<style type='text/css'>";
    $ReturnString .= $Custom_CSS;
    $ReturnString .= "</style>";
    /**
     * @var string $redirect_field
     * @var string $redirect_page
     * @var string $redirect_array_string
     */
    if ($feup_success and $redirect_field != "") {
        $redirect_page = Determine_Redirect_Page($redirect_field, $redirect_array_string, $redirect_page);
    }
    if ($feup_success and $redirect_page != '#') {
        $CheckCookie = CheckLoginCookie();
        $User = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$ewd_feup_user_table_name} WHERE Username='******'", $CheckCookie['Username']));
        if ($User->subscription == "active") {
            $redirect_page = "/your-settings";
        } else {
            $UserData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ewd_feup_user_fields_table_name} WHERE User_ID='%d'", $User->User_ID));
            $expiry_date = null;
            foreach ($UserData as $u) {
                if ($u->Field_Name == "Membership Expiry Date") {
                    $expiry_date = $u->Field_Value;
                }
            }
            //$UserData[10]->Field_Value;
            //compare date here
            if (time() - strtotime($expiry_date) > -3600 * 24) {
                $redirect_page = '/account-expired';
            } elseif ($expiry_date == "") {
                $redirect_page = '/you-did-it';
            } else {
                $redirect_page = '/your-settings';
            }
        }
        FEUPRedirect($redirect_page);
    }
    $ReturnString .= "<div id='ewd-feup-login-form-div'>";
    if (isset($user_message['Message'])) {
        $ReturnString .= $user_message['Message'];
    }
    $ReturnString .= "<form action='#' method='post' id='ewd-feup-login-form' class='pure-form pure-form-aligned'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-check' value='" . sha1(md5($Time . $Salt)) . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-time' value='" . $Time . "'>";
    $ReturnString .= "<input type='hidden' name='ewd-feup-action' value='login'>";
    $ReturnString .= "<div class='pure-control-group'>";
    if ($Username_Is_Email == "Yes") {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label'>Phone</label>";
        $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' placeholder='Phone Number...'>";
    } else {
        $ReturnString .= "<label for='Username' id='ewd-feup-login-username-div' class='ewd-feup-field-label'>Phone Number: </label>";
        $ReturnString .= "<input type='text' class='ewd-feup-text-input' name='Username' placeholder='Phone Number...'>";
    }
    $ReturnString .= "</div>";
    $ReturnString .= "<div class='pure-control-group'>";
    $ReturnString .= "<label for='Password' id='ewd-feup-login-password-div' class='ewd-feup-field-label'>" . __('Password', 'EWD_FEUP') . "</label>";
    $ReturnString .= "<input type='password' class='ewd-feup-text-input' name='User_Password'>";
    $ReturnString .= "</div>";
    $ReturnString .= "<input type='submit' class='ewd-feup-submit pure-button pure-button-primary' name='Login_Submit' value='" . $submit_text . "'>";
    $ReturnString .= "</form>";
    $ReturnString .= "</div>";
    return $ReturnString;
}