function EWD_FEUP_Filter_Page_Content($content) { global $wpdb, $ewd_feup_user_table_name, $ewd_feup_levels_table_name; $ID = get_the_ID(); $FEUP_Level_Type = get_post_meta($ID, "ewd-feup-level-type-dropdown", true); $FEUP_Level = get_post_meta($ID, "ewd-feup-level-dropdown", true); if ($FEUP_Level > 0) { $Delete_Content = "Yes"; $User = new FEUP_User(); if ($User->Is_Logged_In()) { $Level_ID = $wpdb->get_var("SELECT Level_ID FROM {$ewd_feup_user_table_name} WHERE User_ID='" . $User->Get_User_ID() . "'"); $Level = $wpdb->get_var("SELECT Level_Privilege FROM {$ewd_feup_levels_table_name} WHERE Level_ID='" . $Level_ID . "'"); if ($FEUP_Level_Type == "minimum_level") { if ($Level >= $FEUP_Level) { $Delete_Content = "No"; } } elseif ($FEUP_Level_Type == "level") { if ($Level == $FEUP_Level) { $Delete_Content = "No"; } } elseif ($FEUP_Level_Type == "maximum_level") { if ($Level <= $FEUP_Level) { $Delete_Content = "No"; } } } if ($Delete_Content == "Yes") { $content = __("Please log in to access this content.", 'EWD_FEUP'); } } return $content; }
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; }
function Insert_Login_Logout_Toggle($atts) { global $user_message, $feup_success; $Salt = get_option("EWD_FEUP_Hash_Salt"); $Custom_CSS = get_option("EWD_FEUP_Custom_CSS"); $Time = time(); $ReturnString = ""; // Get the attributes passed by the shortcode, and store them in new variables for processing extract(shortcode_atts(array('login_redirect_page' => '#', 'logout_redirect_page' => '#'), $atts)); $User = new FEUP_User(); if (!$User->Is_Logged_In()) { return do_shortcode("[login redirect_page='" . $login_redirect_page . "']"); } elseif (isset($_POST['Logout_Submit'])) { return do_shortcode("[logout redirect_page='" . $logout_redirect_page . "']"); } else { $ReturnString .= "<style type='text/css'>"; $ReturnString .= $Custom_CSS; $ReturnString .= "</style>"; $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='feup-pure-form 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'>"; $ReturnString .= "<label for='Logout_Submit'></label><input type='submit' class='ewd-feup-submit feup-pure-button feup-pure-button-primary' name='Logout_Submit' value='" . __('Logout', 'EWD_FEUP') . "'>"; $ReturnString .= "</div>"; $ReturnString .= "</form>"; $ReturnString .= "</div>"; return $ReturnString; } }
<?php $FEUP = new FEUP_User(); /****************************************** * DIFFERENT MENU FOR LOGGED IN USERS ******************************************/ // Test if a user is logged in if ($FEUP->Is_Logged_In()) { // Display the menu named "Logged In Menu" if they are (created under "Appearances" -> "Menus" of the WordPress Admin) wp_nav_menu(array('menu' => 'Logged In Menu')); } else { // Display the menu named "Logged Out Menu" if they aren't wp_nav_menu(array('menu' => 'Logged Out Menu')); } /****************************************** * DISPLAY POST BASED ON A USER'S INTERESTS ******************************************/ // Get the field value for the "Interests" field $Interests_String = $FEUP->Get_Field_Value("Interests"); // Turn the string containing a user's interests into an array $Interests = explode(",", $Interests_String); // Check if lighting is in the array, and display posts in the "Lighting" category if it is if (in_array("Lighting", $Interests)) { // this user is interested in lighting, display the lighting posts category here } /***************************************** * THE FOUR HELPER FUNCTIONS *****************************************/ // Retrieve the user's ID $User_ID = $FEUP->Get_User_ID(); // Retrieve the user's username
function EWD_FEUP_Admin_Head() { global $EWD_FEUP_Full_Version; $Track_Events = get_option("EWD_FEUP_Track_Events"); $User = new FEUP_User(); if ($User->Is_Logged_In() and $EWD_FEUP_Full_Version == "Yes" and $Track_Events == "Yes") { echo "<script>var User_ID = " . $User->Get_User_ID() . ";\n"; echo "if (typeof(ajaxurl) == 'undefined' || ajaxurl === null) {"; echo "var ajaxurl = '" . admin_url('admin-ajax.php') . "';\n"; echo "}"; echo "</script>"; } }
function EWD_FEUP_WooCommerce_Field_Overide($fields) { $User = new FEUP_User(); $First_Name_Field = get_option('EWD_FEUP_WooCommerce_First_Name_Field'); $Last_Name_Field = get_option('EWD_FEUP_WooCommerce_Last_Name_Field'); $Company_Field = get_option('EWD_FEUP_WooCommerce_Company_Field'); $Address_Line_One_Field = get_option('EWD_FEUP_WooCommerce_Address_Line_One_Field'); $Address_Line_Two_Field = get_option('EWD_FEUP_WooCommerce_Address_Line_Two_Field'); $City_Field = get_option('EWD_FEUP_WooCommerce_City_Field'); $Postcode_Field = get_option('EWD_FEUP_WooCommerce_Postcode_Field'); $Country_Field = get_option('EWD_FEUP_WooCommerce_Country_Field'); $State_Field = get_option('EWD_FEUP_WooCommerce_State_Field'); $Email_Field = get_option('EWD_FEUP_WooCommerce_Email_Field'); $Phone_Field = get_option('EWD_FEUP_WooCommerce_Phone_Field'); $First_Name = $User->Get_Field_Value($First_Name_Field); $Last_Name = $User->Get_Field_Value($Last_Name_Field); $Company = $User->Get_Field_Value($Company_Field); $Address_Line_One = $User->Get_Field_Value($Address_Line_One_Field); $Address_Line_Two = $User->Get_Field_Value($Address_Line_Two_Field); $City = $User->Get_Field_Value($City_Field); $Postcode = $User->Get_Field_Value($Postcode_Field); $Country = $User->Get_Field_Value($Country_Field); $State = $User->Get_Field_Value($State_Field); $Email = $User->Get_Field_Value($Email_Field); $Phone = $User->Get_Field_Value($Phone_Field); if ($First_Name != "") { $fields['billing']['billing_first_name']['default'] = $First_Name; $fields['shipping']['shipping_first_name']['default'] = $First_Name; } if ($Last_Name != "") { $fields['billing']['billing_last_name']['default'] = $Last_Name; $fields['shipping']['shipping_last_name']['default'] = $Last_Name; } if ($Company != "") { $fields['billing']['billing_company']['default'] = $Company; $fields['shipping']['shipping_company']['default'] = $Company; } if ($Address_Line_One != "") { $fields['billing']['billing_address_1']['default'] = $Address_Line_One; $fields['shipping']['shipping_address_1']['default'] = $Address_Line_One; } if ($Address_Line_Two != "") { $fields['billing']['billing_address_2']['default'] = $Address_Line_Two; $fields['shipping']['shipping_address_2']['default'] = $Address_Line_Two; } if ($City != "") { $fields['billing']['billing_city']['default'] = $City; $fields['shipping']['shipping_city']['default'] = $City; } if ($Postcode != "") { $fields['billing']['billing_postcode']['default'] = $Postcode; $fields['shipping']['shipping_postcode']['default'] = $Postcode; } if ($Country != "") { $fields['billing']['billing_country']['default'] = $Country; $fields['shipping']['shipping_country']['default'] = $Country; } if ($State != "") { $fields['billing']['billing_state']['default'] = $State; $fields['shipping']['shipping_state']['default'] = $State; } if ($Email != "") { $fields['billing']['billing_email']['default'] = $Email; $fields['shipping']['shipping_email']['default'] = $Email; } if ($Phone != "") { $fields['billing']['billing_phone']['default'] = $Phone; $fields['shipping']['shipping_phone']['default'] = $Phone; } return $fields; }