/** * Display social login interface in widget area. */ public static function login_radius_widget_connect_button() { global $loginRadiusSettings, $user_ID; if (!is_user_logged_in()) { Login_Helper::get_loginradius_interface_container(); } // On user Login show user details. if (is_user_logged_in() && !is_admin()) { $size = '60'; $user = get_userdata($user_ID); $currentSocialId = get_user_meta($user_ID, 'loginradius_current_id', true); // hold the value of avatar option echo "<div style='height:80px;width:180px'><div style='width:63px;float:left;'>"; echo @get_avatar($user_ID, $size, $default, $alt); echo "</div><div style='width:100px; float:left; margin-left:10px'>"; // username separator if (!isset($loginRadiusSettings['username_separator']) || $loginRadiusSettings['username_separator'] == 'dash') { echo $user->user_login; } elseif (isset($loginRadiusSettings['username_separator']) && $loginRadiusSettings['username_separator'] == 'dot') { echo str_replace('-', '.', $user->user_login); } else { echo str_replace('-', ' ', $user->user_login); } if (isset($loginRadiusSettings['LoginRadius_loutRedirect']) && $loginRadiusSettings['LoginRadius_loutRedirect'] == 'custom' && !empty($loginRadiusSettings['custom_loutRedirect'])) { $redirect = htmlspecialchars($loginRadiusSettings['custom_loutRedirect']); } else { $redirect = home_url(); ?> <?php } ?> <br/><a href="<?php echo wp_logout_url($redirect); ?> "><?php _e('Log Out', 'LoginRadius'); ?> </a></div></div><?php } }
/** * Displaying account linking on profile page */ public static function account_linking_info_on_profile_page() { global $pagenow, $lr_custom_interface_settings; $user_Id = get_current_user_id(); if (isset($loginRadiusSettings['LoginRadius_socialLinking']) && $loginRadiusSettings['LoginRadius_socialLinking'] == '1' || !$user_Id == '1') { return; } $custom = false; if (isset($lr_custom_interface_settings['custom_interface']) && $lr_custom_interface_settings['custom_interface'] == '1') { $custom = true; } if ($pagenow == 'profile.php') { if (!class_exists('LR_Raas_Install')) { echo LR_Common::check_linking_status_parameters(); // If remove button clicked if (isset($_GET['loginRadiusMap']) && !empty($_GET['loginRadiusMap']) && isset($_GET['loginRadiusMappingProvider']) && !empty($_GET['loginRadiusMappingProvider'])) { Login_Helper::unlink_provider(); } LR_Common::link_account_if_possible(); ?> <div class="metabox-holder columns-2" id="post-body"> <div class="stuffbox wrap" style="padding-bottom:10px"> <h3><label><?php _e('Link your account', 'LoginRadius'); ?> </label></h3> <div class="inside" style='padding:0'> <table class="form-table editcomment"> <tr> <td colspan="2"><?php _e('By adding another account, you can log in with the new account as well!', 'LoginRadius'); ?> </td> </tr> <tr> <td colspan="2"> <?php if (!class_exists("Login_Helper")) { require_once LOGINRADIUS_PLUGIN_DIR . 'public/inc/login/class-login-helper.php'; } Login_Helper::get_loginradius_interface_container(); ?> </td> </tr> <?php echo LR_Common::get_connected_providers_list(); ?> </table> </div> </div> </div> <?php } else { do_action('lr_raas_social_linking'); } } }
/** * Loading Login Script for loggedin user to provide account linking */ public static function load_login_script($isLinkingWidget = false) { if (!class_exists('LR_Raas_Install')) { global $pagenow, $loginRadiusObject, $loginRadiusSettings, $loginradius_api_settings, $lr_custom_interface_settings, $linking_bool, $loginRadiusLoginIsBpActive; $loginradius_api_settings['LoginRadius_apikey'] = isset($loginradius_api_settings['LoginRadius_apikey']) ? trim($loginradius_api_settings['LoginRadius_apikey']) : ''; if (!class_exists("Login_Helper")) { require_once LOGINRADIUS_PLUGIN_DIR . 'public/inc/login/class-login-helper.php'; } $register = Login_Helper::is_register_page(); $location = urlencode(Login_Helper::get_redirect_url('', $register)); if (isset($lr_custom_interface_settings['custom_interface']) && $lr_custom_interface_settings['custom_interface'] == '1') { if (isset($lr_custom_interface_settings['selected_providers']) && $lr_custom_interface_settings['selected_providers'] != '') { $selected_providers = implode('\',\'', $lr_custom_interface_settings['selected_providers']); } $interface_url = LR_CUSTOM_INTERFACE_URL . 'assets/images/custom_interface/'; if (is_multisite()) { $interface_url .= get_current_blog_id() . '/'; } ?> <script type="text/javascript"> function detectmob() { if ( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ) { return true; } else { return false; } } </script> <script type="text/javascript"> jQuery(document).ready(function(){ $LRIC.util.ready(function() { var options = {}; options.apikey = "<?php echo isset($loginradius_api_settings['LoginRadius_apikey']) ? trim($loginradius_api_settings['LoginRadius_apikey']) : ''; ?> "; options.appname = "<?php echo isset($loginradius_api_settings['sitename']) ? $loginradius_api_settings['sitename'] : ''; ?> "; <?php if (isset($lr_custom_interface_settings['selected_providers'])) { ?> options.providers = [<?php echo "'" . $selected_providers . "'"; ?> ]; <?php } ?> if ( detectmob() ) { options.templatename = "loginradiuscustom_tmpl_mobile"; } else { options.templatename = "loginradiuscustom_tmpl"; } $LRIC.renderInterface("interfacecontainerdiv", options); }); }); </script> <script type="text/html" id="loginradiuscustom_tmpl"> <a class="lr_custom_provider" onclick="return $LRIC.util.openWindow('<%=Endpoint%>&callback=<?php echo $location; ?> &is_access_token=true');"><img src="<?php echo $interface_url; ?> <%=Name.toLowerCase() %>.png" /></a> </script> <script type="text/html" id="loginradiuscustom_tmpl_mobile"> <a class="lr_custom_provider" onclick="return $LRIC.util.openWindow('<%=Endpoint%>&callback=<?php echo $location; ?> &callbacktype=hash&isParentWindowLogin=true&is_access_token=true');"><img src="<?php echo $interface_url; ?> <%=Name.toLowerCase() %>.png" /></a> </script> <?php } else { ?> <script type="text/javascript"> function detectmob() { if ( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ) { return true; } else { return false; } } </script> <script type="text/javascript"> jQuery(document).ready(function() { var loginRadiusOptions = {}; loginRadiusOptions.login = true; //Disabling console log messages - please delete when api has been updated LoginRadius_SocialLogin.console.log = function(){}; LoginRadius_SocialLogin.util.ready( function() { $ui = LoginRadius_SocialLogin.lr_login_settings; $ui.interfacesize = ''; $ui.apikey = "<?php echo $loginradius_api_settings['LoginRadius_apikey']; ?> "; $ui.callback = "<?php echo $location; ?> "; $ui.lrinterfacecontainer = "interfacecontainerdiv"; $ui.is_access_token = true; if( detectmob() ) { $ui.callbacktype = "hash"; $ui.isParentWindowLogin = true; } <?php if (isset($loginRadiusSettings["LoginRadius_interfaceSize"]) && $loginRadiusSettings["LoginRadius_interfaceSize"] == "small") { echo '$ui.interfacesize ="small";'; } if (isset($loginRadiusSettings['LoginRadius_numColumns']) && trim($loginRadiusSettings['LoginRadius_numColumns']) != '') { echo '$ui.noofcolumns = ' . trim($loginRadiusSettings['LoginRadius_numColumns']) . ';'; } if (isset($loginRadiusSettings['LoginRadius_backgroundColor'])) { echo '$ui.lrinterfacebackground = "' . trim($loginRadiusSettings['LoginRadius_backgroundColor']) . '";'; } ?> LoginRadius_SocialLogin.init( loginRadiusOptions ); }); }); </script> <?php } ?> <script type="text/javascript"> jQuery(document).ready(function(){ LoginRadiusSDK.setLoginCallback(function() { var form = document.createElement('form'); form.action = "<?php echo urldecode($location); ?> "; form.method = 'POST'; var hiddenToken = document.createElement('input'); hiddenToken.type = 'hidden'; hiddenToken.value = LoginRadiusSDK.getToken(); hiddenToken.name = "token"; form.appendChild(hiddenToken); document.body.appendChild(form); form.submit(); }); }); </script> <?php } }
/** * populate email asking popup */ function login_radius_email_popup() { global $wpdb, $loginRadiusSettings, $lr_social_profile_data_settings; if (isset($_GET['key']) && $_GET['key'] != '') { $loginRadiusTempUserId = $wpdb->get_var($wpdb->prepare('SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE meta_key=\'tmpsession\' AND meta_value = %s', $_GET['key'])); $provider = get_user_meta($loginRadiusTempUserId, 'tmpProvider', true); $profileData = Login_Helper::fetch_temp_data_from_usermeta($loginRadiusTempUserId); // Custom Popup if (isset($lr_social_profile_data_settings['enable_custom_popup']) && $lr_social_profile_data_settings['enable_custom_popup'] == '1') { //Has Email from provider or from dummy email $has_email = isset($profileData['Email']) && !empty($profileData['Email']) ? true : false; $notdummyemail = isset($loginRadiusSettings['LoginRadius_dummyemail']) && $loginRadiusSettings['LoginRadius_dummyemail'] == 'notdummyemail' ? true : false; // Format date for input field. if (!empty($profileData['BirthDate'])) { $datebool = strpos($profileData['BirthDate'], '-'); // Date format matches mm/dd/YYYY if (!$datebool) { $date = explode('/', $profileData['BirthDate']); $month = $date[0] - 1; $day = $date[1]; $year = $date[2]; // Add 0 to all months less than 10 if ($date[0] < 10) { $date[0] = '0' . $date[0]; } // Add 0 to all days less than 10 if ($date[1] < 10) { $date[1] = '0' . $date[1]; } // Format YYYY-mm-dd $profileData['BirthDate'] = $date[2] . '-' . $date[0] . '-' . $date[1]; } else { $date = explode('-', $profileData['BirthDate']); $year = $date[0]; $month = $date[1]; $day = $date[2]; // Format YYYY-mm-dd $profileData['BirthDate'] = $year . '-' . $month . '-' . $day; } } ?> <script> jQuery(document).ready(function() { jQuery('#birthdate').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'yy-mm-dd', yearRange: "-100:+0", <?php if (!empty($profileData['BirthDate'])) { ?> defaultDate: new Date(<?php echo $year . ',' . $month . ',' . $day; ?> ) <?php } ?> }); }); </script> <div class="LoginRadius_overlay" id="fade"> <div id="popupouter"> <div class="lr-popupheading"> Required Fields</div> <div id="popupinner"> <div id="loginRadiusError" style = "display: none;"></div> <?php if ($has_email) { if ($_GET['isError'] == 'yes') { echo '<div id="textmatter" class="lr-noerror" style = "background-color: rgb(255, 235, 232);border: 1px solid rgb(204, 0, 0);">'; if (isset($_GET['message']) && $_GET['message'] != '') { echo str_replace('@provider', $provider, $_GET['message']); } echo '</div><!-- END TEXTMATTER DIV -->'; } } else { if ($_GET['isError'] == 'yes') { echo '<div id="textmatter" class="lr-noerror" style = "background-color: rgb(255, 235, 232);border: 1px solid rgb(204, 0, 0);">'; } else { echo '<div id="textmatter" class="lr-noerror">'; } if (isset($_GET['message']) && $_GET['message'] != '') { echo str_replace('@provider', $provider, $_GET['message']); } ?> </div><!-- END TEXTMATTER DIV --> <?php } ?> <form method="post" id="popup_form" style = "height: 50px;"> <?php if (!$has_email && $notdummyemail && (isset($lr_social_profile_data_settings['show_email']) && $lr_social_profile_data_settings['show_email'] == '1' || isset($loginRadiusSettings['LoginRadius_dummyemail']) && $loginRadiusSettings['LoginRadius_dummyemail'] == 'notdummyemail')) { ?> <div> <div class="emailtext" id="innerp">Enter your email:</div> <input type="text" name="email" id="loginRadiusEmail" class="inputtxt" style = "padding-top: 0px;" data-validation="email" value="<?php echo $profileData['Email']; ?> "/> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_gender']) && $lr_social_profile_data_settings['show_gender'] == '1') { ?> <div> <div id="innerp">Select your Gender:</div> <input type="radio" name="gender" value="male" <?php echo isset($profileData['Gender']) && $profileData['Gender'] == 'M' || $profileData['Gender'] == 'male' ? 'checked' : ''; ?> />Male <input type="radio" name="gender" value="female" <?php echo isset($profileData['Gender']) && $profileData['Gender'] == 'F' || $profileData['Gender'] == 'female' ? 'checked' : ''; ?> />Female </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_birthdate']) && $lr_social_profile_data_settings['show_birthdate'] == '1') { ?> <div> <div id="innerp">Select your BirthDate:</div> <input class="inputtxt" type="text" id="birthdate" name="birthdate" data-validation="date" data-validation-format="yyyy-mm-dd" value="<?php echo $profileData['BirthDate']; ?> "/> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_phonenumber']) && $lr_social_profile_data_settings['show_phonenumber'] == '1') { ?> <div> <div id="innerp">Enter your Phone Number:</div> <input class="inputtxt" type="text" name="phonenumber" data-validation="required" data-validation-length="min10" value="<?php echo $profileData['PhoneNumber']; ?> "/> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_city']) && $lr_social_profile_data_settings['show_city'] == '1') { ?> <div> <div id="innerp">Enter your City:</div> <input class="inputtxt" type="text" name="city" data-validation="required" value="<?php echo $profileData['City']; ?> "/> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_postalcode']) && $lr_social_profile_data_settings['show_postalcode'] == '1') { ?> <div> <div id="innerp">Enter your Postal Code:</div> <input class="inputtxt" type="text" name="postalcode" data-validation="required" value="<?php echo $profileData['PostalCode']; ?> "/> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_relationshipstatus']) && $lr_social_profile_data_settings['show_relationshipstatus'] == '1') { ?> <div> <div id="innerp">Enter your Relationship Status:</div> <input class="inputtxt" type="text" name="relationshipstatus" data-validation="required" value="<?php echo $profileData['RelationshipStatus']; ?> "/> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_custom_one']) && $lr_social_profile_data_settings['show_custom_one'] == '1') { ?> <div> <div id="innerp"><?php echo $lr_social_profile_data_settings['custom_one_title']; ?> </div> <?php if (isset($lr_social_profile_data_settings['custom_one_type']) && $lr_social_profile_data_settings['custom_one_type'] == 'dropdown') { $dropdown_id = $wpdb->get_var($wpdb->prepare("SELECT field_id FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_map WHERE field_name = %s", 'field_1')); $dropdown_values = $wpdb->get_results($wpdb->prepare("SELECT field_value FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_dropdown WHERE field_id = %d", $dropdown_id), 'ARRAY_A'); ?> <select class="inputtxt" name="field_1"> <?php for ($i = 0; $i < count($dropdown_values); $i++) { $selected = isset($profileData['Field_1']) && $profileData['Field_1'] == $dropdown_values[$i]['field_value'] ? "selected" : ''; echo '<option value="' . $dropdown_values[$i]['field_value'] . '" ' . $selected . '>' . $dropdown_values[$i]['field_value'] . '</option>'; } ?> </select> <?php } else { ?> <input class="inputtxt" type="text" name="field_1" data-validation="required" value="<?php echo $profileData['Field_1']; ?> "/> <?php } ?> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_custom_two']) && $lr_social_profile_data_settings['show_custom_two'] == '1') { ?> <div> <div id="innerp"><?php echo $lr_social_profile_data_settings['custom_two_title']; ?> </div> <?php if (isset($lr_social_profile_data_settings['custom_two_type']) && $lr_social_profile_data_settings['custom_two_type'] == 'dropdown') { $dropdown_id = $wpdb->get_var($wpdb->prepare("SELECT field_id FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_map WHERE field_name = %s", 'field_2')); $dropdown_values = $wpdb->get_results($wpdb->prepare("SELECT field_value FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_dropdown WHERE field_id = %d", $dropdown_id), 'ARRAY_A'); ?> <select class="inputtxt" name="field_2"> <?php for ($i = 0; $i < count($dropdown_values); $i++) { $selected = isset($profileData['Field_2']) && $profileData['Field_2'] == $dropdown_values[$i]['field_value'] ? "selected" : ''; echo '<option value="' . $dropdown_values[$i]['field_value'] . '" ' . $selected . '>' . $dropdown_values[$i]['field_value'] . '</option>'; } ?> </select> <?php } else { ?> <input class="inputtxt" type="text" name="field_2" data-validation="required" value="<?php echo $profileData['Field_2']; ?> "/> <?php } ?> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_custom_three']) && $lr_social_profile_data_settings['show_custom_three'] == '1') { ?> <div> <div id="innerp"><?php echo $lr_social_profile_data_settings['custom_three_title']; ?> </div> <?php if (isset($lr_social_profile_data_settings['custom_three_type']) && $lr_social_profile_data_settings['custom_three_type'] == 'dropdown') { $dropdown_id = $wpdb->get_var($wpdb->prepare("SELECT field_id FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_map WHERE field_name = %s", 'field_3')); $dropdown_values = $wpdb->get_results($wpdb->prepare("SELECT field_value FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_dropdown WHERE field_id = %d", $dropdown_id), 'ARRAY_A'); ?> <select class="inputtxt" name="field_3"> <?php for ($i = 0; $i < count($dropdown_values); $i++) { $selected = isset($profileData['Field_3']) && $profileData['Field_3'] == $dropdown_values[$i]['field_value'] ? "selected" : ''; echo '<option value="' . $dropdown_values[$i]['field_value'] . '" ' . $selected . '>' . $dropdown_values[$i]['field_value'] . '</option>'; } ?> </select> <?php } else { ?> <input class="inputtxt" type="text" name="field_3" data-validation="required" value="<?php echo $profileData['Field_3']; ?> "/> <?php } ?> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_custom_four']) && $lr_social_profile_data_settings['show_custom_four'] == '1') { ?> <div> <div id="innerp"><?php echo $lr_social_profile_data_settings['custom_four_title']; ?> </div> <?php if (isset($lr_social_profile_data_settings['custom_four_type']) && $lr_social_profile_data_settings['custom_four_type'] == 'dropdown') { $dropdown_id = $wpdb->get_var($wpdb->prepare("SELECT field_id FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_map WHERE field_name = %s", 'field_4')); $dropdown_values = $wpdb->get_results($wpdb->prepare("SELECT field_value FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_dropdown WHERE field_id = %d", $dropdown_id), 'ARRAY_A'); ?> <select class="inputtxt" name="field_4"> <?php for ($i = 0; $i < count($dropdown_values); $i++) { $selected = isset($profileData['Field_4']) && $profileData['Field_4'] == $dropdown_values[$i]['field_value'] ? "selected" : ''; echo '<option value="' . $dropdown_values[$i]['field_value'] . '" ' . $selected . '>' . $dropdown_values[$i]['field_value'] . '</option>'; } ?> </select> <?php } else { ?> <input class="inputtxt" type="text" name="field_4" data-validation="required" value="<?php echo $profileData['Field_4']; ?> "/> <?php } ?> </div> <?php } ?> <?php if (isset($lr_social_profile_data_settings['show_custom_five']) && $lr_social_profile_data_settings['show_custom_five'] == '1') { ?> <div> <div id="innerp"><?php echo $lr_social_profile_data_settings['custom_five_title']; ?> </div> <?php if (isset($lr_social_profile_data_settings['custom_five_type']) && $lr_social_profile_data_settings['custom_five_type'] == 'dropdown') { $dropdown_id = $wpdb->get_var($wpdb->prepare("SELECT field_id FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_map WHERE field_name = %s", 'field_5')); $dropdown_values = $wpdb->get_results($wpdb->prepare("SELECT field_value FROM " . $wpdb->base_prefix . "loginradius_popup_custom_fields_dropdown WHERE field_id = %d", $dropdown_id), 'ARRAY_A'); ?> <select class="inputtxt" name="field_5"> <?php for ($i = 0; $i < count($dropdown_values); $i++) { $selected = isset($profileData['Field_5']) && $profileData['Field_5'] == $dropdown_values[$i]['field_value'] ? "selected" : ''; echo '<option value="' . $dropdown_values[$i]['field_value'] . '" ' . $selected . '>' . $dropdown_values[$i]['field_value'] . '</option>'; } ?> </select> <?php } else { ?> <input class="inputtxt" type="text" name="field_5" data-validation="required" value="<?php echo $profileData['Field_5']; ?> "/> <?php } ?> </div> <?php } ?> <div class="footerbox"> <input type="submit" id="LoginRadius_popupSubmit" name="LoginRadius_popupSubmit" value="Submit" class="inputbutton"> <input type="hidden" value="<?php echo $_GET['key']; ?> " name = "session"/> </form> <form method = "post"> <input type="submit" name="LoginRadius_popupSubmit" value="Cancel" class="inputbutton" /> <input type="hidden" value="<?php echo $_GET['key']; ?> " name = "session"/> </form> </div><!-- END FOOTERBOX --> </div> </div> </div> <script> jQuery.validate(); </script> <?php } else { ?> <div class="LoginRadius_overlay" id="fade"> <div id="popupouter"> <div class="lr-popupheading"> You are trying to connect with <?php echo $provider; ?> </div> <div id="popupinner"> <div id="loginRadiusError" style = "display: none;"></div> <?php if ($_GET['isError'] == 'yes') { echo '<div id="textmatter" class="lr-noerror" style = "background-color: rgb(255, 235, 232);border: 1px solid rgb(204, 0, 0);">'; } else { echo '<div id="textmatter" class="lr-noerror">'; } if (isset($_GET['message']) && $_GET['message'] != '') { echo str_replace('@provider', $provider, $_GET['message']); } $_GET['message']; ?> </div> <div class="emailtext" id="innerp">Enter your email:</div> <form method="post" action='' onsubmit='return loginRadiusValidateEmail()' style = "height: 50px;"> <div> <input type="text" name="email" id="loginRadiusEmail" class="inputtxt" style = "padding-top: 0px;"/> </div> <div class="footerbox"> <input type="submit" id="LoginRadius_popupSubmit" name="LoginRadius_popupSubmit" value="Submit" class="inputbutton"> <input type="hidden" value="<?php echo $_GET['key']; ?> " name = "session"/> </form> <form method = "post"> <input type="submit" name="LoginRadius_popupSubmit" value="Cancel" class="inputbutton" /> <input type="hidden" value="<?php echo $_GET['key']; ?> " name = "session"/> </form> </div><!-- END FOOTERBOX --> </div> </div> </div> <?php } } die; }
/** * Callback for Social Linking widget shortcode */ public static function linking_widget_shortcode() { global $loginRadiusObject, $loginradius_api_settings, $lr_custom_interface_settings; if (!is_user_logged_in()) { return ''; } $custom = false; if (isset($lr_custom_interface_settings['custom_interface']) && $lr_custom_interface_settings['custom_interface'] == '1') { $custom = true; } $html = LR_Common::check_linking_status_parameters(); if (!($loginRadiusObject->loginradius_is_valid_guid(trim($loginradius_api_settings['LoginRadius_apikey'])) && $loginRadiusObject->loginradius_is_valid_guid(trim($loginradius_api_settings['LoginRadius_secret'])))) { $html .= '<div style="color:red">' . __('Your LoginRadius API key or secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b>', 'LoginRadius') . '</div>'; } // function call LR_Common::link_account_if_possible(); if (!($loginRadiusObject->loginradius_is_valid_guid(trim($loginradius_api_settings['LoginRadius_apikey'])) && $loginRadiusObject->loginradius_is_valid_guid(trim($loginradius_api_settings['LoginRadius_secret'])))) { $html .= '<div style="color:red">' . __('Your LoginRadius API key or secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b>', 'LoginRadius') . '</div>'; } $html .= Login_Helper::get_loginradius_interface_container(true); $html .= '<table class="loginRadiusLinking">'; $html .= LR_Common::get_connected_providers_list(); $html .= '</table>'; return $html; }
/** * This function is called when token is returned from LoginRadius. * it checks for query string variable and fetches data using LoginRadius api. * After fetching data, appropriate action is taken on the basis of LoginRadius plugin settings */ public static function login_radius_connect() { global $wpdb, $loginRadiusSettings, $loginRadiusObject, $lr_social_profile_data_settings; if (isset($_GET['loginradius_linking']) && isset($_REQUEST['token'])) { LR_Common::perform_linking_operation(); } if (isset($_GET['loginRadiusVk']) && trim($_GET['loginRadiusVk']) != '') { //If verification link is clicked Login_Helper::verify_user_after_email_confirmation(); } if (isset($_POST['LoginRadius_popupSubmit'])) { //If "email required" popup has been submitted Login_helper::response_to_popup_submission(); } // If remove button clicked if (isset($_GET['loginRadiusMap']) && !empty($_GET['loginRadiusMap']) && isset($_GET['loginRadiusMappingProvider']) && !empty($_GET['loginRadiusMappingProvider']) && is_user_logged_in()) { Login_Helper::unlink_provider(); } if (!is_user_logged_in() && isset($_REQUEST['token'])) { $token = $_REQUEST['token']; try { // Fetch user profile using access token ...... $responseFromLoginRadius = $loginRadiusObject->loginradius_get_user_profiledata($token); } catch (LoginRadiusException $e) { // Error Handling if ($loginRadiusSettings['enable_degugging'] == '0') { // if debugging is off and Social profile not recieved, redirect to home page. wp_redirect(site_url()); exit; } else { $responseFromLoginRadius = null; $message = isset($e->getErrorResponse()->description) ? $e->getErrorResponse()->description : $e->getMessage(); error_log($message); // If debug option is set and Social Profile not retrieved Login_Helper::login_radius_notify($message, 'isProfileNotRetrieved'); return; } } if (isset($responseFromLoginRadius->ID) && $responseFromLoginRadius->ID != null) { // If profile data is retrieved successfully self::$loginRadiusProfileData = Login_Helper::filter_loginradius_data_for_wordpress_use($responseFromLoginRadius); } $userId = Login_Helper::is_socialid_exists_in_wordpress(self::$loginRadiusProfileData); if ($userId) { //if Social id exists in wordpress database if (1 == get_user_meta($userId, self::$loginRadiusProfileData['Provider'] . 'LrVerified', true) || class_exists('LR_Raas_Install')) { // if user is verified, provide login. Login_Helper::login_user($userId, self::$loginRadiusProfileData); } else { // If not verified then display pop up. Login_Helper::login_radius_notify(__('Please verify your email by clicking the confirmation link sent to you.', 'LoginRadius'), 'isEmailNotVerified'); return; } } // check if id already exists. $loginRadiusUserId = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM " . $wpdb->usermeta . " WHERE meta_key='loginradius_provider_id' AND meta_value = %s", self::$loginRadiusProfileData['ID'])); if (!empty($loginRadiusUserId)) { // id exists $tempUserId = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id = %d and meta_key='loginradius_isVerified'", $loginRadiusUserId)); if (!empty($tempUserId)) { // check if verification field exists. $isVerified = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM " . $wpdb->usermeta . " WHERE user_id = %d and meta_key='loginradius_isVerified'", $loginRadiusUserId)); if ($isVerified == '1') { // if email is verified Login_Helper::login_user($loginRadiusUserId, self::$loginRadiusProfileData); return; } else { Login_Helper::login_radius_notify(__('Please verify your email by clicking the confirmation link sent to you.', 'LoginRadius'), 'isEmailNotVerified'); return; } } else { Login_Helper::login_user($loginRadiusUserId, self::$loginRadiusProfileData); return; } } else { // Email is empty for social profile data. $dummyEmail = isset($loginRadiusSettings['LoginRadius_dummyemail']) ? $loginRadiusSettings['LoginRadius_dummyemail'] : ''; // Create dummy email. if (empty(self::$loginRadiusProfileData['Email']) && $dummyEmail == 'dummyemail') { // Email not required according to plugin settings self::$loginRadiusProfileData['Email'] = Login_Helper::generate_dummy_email(self::$loginRadiusProfileData); } // Retrieve Profile Data in Popup - Custom popup enabled if (isset($lr_social_profile_data_settings['enable_custom_popup']) && $lr_social_profile_data_settings['enable_custom_popup'] == '1') { //Has Email from provider or from dummy email $has_email = isset(self::$loginRadiusProfileData['Email']) && !empty(self::$loginRadiusProfileData['Email']) ? true : false; $notdummyemail = isset($loginRadiusSettings['LoginRadius_dummyemail']) && $loginRadiusSettings['LoginRadius_dummyemail'] == 'notdummyemail' ? true : false; $showpopup = false; if (!$has_email && $notdummyemail && isset($lr_social_profile_data_settings['show_email']) && $lr_social_profile_data_settings['show_email'] == '1' || isset($loginRadiusSettings['LoginRadius_dummyemail']) && $loginRadiusSettings['LoginRadius_dummyemail'] == 'notdummyemail') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_gender']) && $lr_social_profile_data_settings['show_gender'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_birthdate']) && $lr_social_profile_data_settings['show_birthdate'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_phonenumber']) && $lr_social_profile_data_settings['show_phonenumber'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_city']) && $lr_social_profile_data_settings['show_city'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_postalcode']) && $lr_social_profile_data_settings['show_postalcode'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_relationshipstatus']) && $lr_social_profile_data_settings['show_relationshipstatus'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_custom_one']) && $lr_social_profile_data_settings['show_custom_one'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_custom_two']) && $lr_social_profile_data_settings['show_custom_two'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_custom_three']) && $lr_social_profile_data_settings['show_custom_three'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_custom_four']) && $lr_social_profile_data_settings['show_custom_four'] == '1') { $showpopup = true; } elseif (isset($lr_social_profile_data_settings['show_custom_five']) && $lr_social_profile_data_settings['show_custom_five'] == '1') { $showpopup = true; } if ($showpopup) { $lrUniqueId = Login_Helper::store_temporary_data(self::$loginRadiusProfileData); $queryString = '?lrid=' . $lrUniqueId; wp_redirect(site_url() . $queryString); exit; } else { Login_Helper::register_user(self::$loginRadiusProfileData); return; } } else { // Normal flow no custom popup. if (empty(self::$loginRadiusProfileData['Email'])) { if ($dummyEmail == 'dummyemail') { Login_Helper::register_user(self::$loginRadiusProfileData); return; } else { // Email required according to plugin settings. $lrUniqueId = Login_Helper::store_temporary_data(self::$loginRadiusProfileData); $queryString = '?lrid=' . $lrUniqueId; wp_redirect(site_url() . $queryString); exit; } } else { // Email is not empty $userObject = get_user_by('email', self::$loginRadiusProfileData['Email']); $loginRadiusUserId = is_object($userObject) ? $userObject->ID : ''; if (!empty($loginRadiusUserId)) { // Email exists $isVerified = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM " . $wpdb->usermeta . " WHERE user_id = %d and meta_key='loginradius_isVerified'", $loginRadiusUserId)); if (!empty($isVerified)) { if ($isVerified == '1') { // Social linking LR_Common::link_account($loginRadiusUserId, self::$loginRadiusProfileData['ID'], self::$loginRadiusProfileData['Provider'], self::$loginRadiusProfileData['ThumbnailImageUrl'], self::$loginRadiusProfileData['Provider'], ''); // Login user Login_Helper::login_user($loginRadiusUserId, self::$loginRadiusProfileData); return; } else { $directorySeparator = DIRECTORY_SEPARATOR; require_once getcwd() . $directorySeparator . 'wp-admin' . $directorySeparator . 'inc' . $directorySeparator . 'user.php'; wp_delete_user($loginRadiusUserId); Login_Helper::register_user(self::$loginRadiusProfileData); } } else { // Link Account LR_Common::link_account($loginRadiusUserId, self::$loginRadiusProfileData['ID'], self::$loginRadiusProfileData['Provider'], self::$loginRadiusProfileData['ThumbnailImageUrl'], self::$loginRadiusProfileData['Provider'], ''); // Login user Login_Helper::login_user($loginRadiusUserId, self::$loginRadiusProfileData); return; } } else { Login_Helper::register_user(self::$loginRadiusProfileData); } } } } } // Authentication ends }