shortcode and caching questions
-
hi
i have a few questions:
1. I would like to be able to hide my loginradius shortcode when a user is logged in. I know this is possible for the widget but i cant figure out how to do it for my shortcode (i need to add the shortcode alongside other plugins which require registration)
2. Is there any best practises for loginradius and caching plugins?
I ask because lately when i have clicked login via a social network, the authentication works but the widget still asks me to login (i know the authentication works becuase if i refresh the page my avatar shows, thus i am logged in)3. Also this one is hard to pin down and describe. Sometimes when i click a social network button from my widget, the window that pops up loads another instance of my website with me logged in in another small window. Normally i would expect a pop to show me authenticating to whichever social network i have chosne, and then automatically close, then showing me as ‘logged in’ (with my avatar showing) on the original page.
I have no idea if this is possible linked to the issue i mentioned in question 2 or notany feedback would be appreciated
(btw, i have done the trouble shooting steps, curl authentication is all working fine)
-
Hi RolandofEld,
Please find the answer to your questions below:
1. I would like to be able to hide my loginradius shortcode when a user is logged in. I know this is possible for the widget but i cant figure out how to do it for my shortcode (i need to add the shortcode alongside other plugins which require registration)
Follow the steps mentioned below to resolve the issue:
1. Open “wp-content/plugins/loginradius-for-wordpress/LoginRadius_function.php” in your favorite code editor.
2. Search following code:function login_radius_login_shortcode($params){
3. Place following code after the code searched above:
if(is_user_logged_in()) return ”;
4. Save the file back. Replace existing file, if prompted.
2. Is there any best practises for loginradius and caching plugins?
I ask because lately when i have clicked login via a social network, the authentication works but the widget still asks me to login (i know the authentication works becuase if i refresh the page my avatar shows, thus i am logged in)
“widget still asks me to login” – It needs some details. Can you provide us website url so that we can investigate the issue?3. Also this one is hard to pin down and describe. Sometimes when i click a social network button from my widget, the window that pops up loads another instance of my website with me logged in in another small window. Normally i would expect a pop to show me authenticating to whichever social network i have chosne, and then automatically close, then showing me as ‘logged in’ (with my avatar showing) on the original page.
I have no idea if this is possible linked to the issue i mentioned in question 2 or not
Navigate to LoginRadius page in WordPress admin panel. Select No in “Release authentication response in ID provider pop-up?” option, save changes and check the issue at your website.Hope this helps!
thank you for your quick reply! the shortcode code works perfectly!!
for question number 2 my site is https://www.italianiaperth.com
hopefully you can help!
thanks!
Hi RolandOfEld,
The title you enter for widget is displayed as is, irrespective of whether the user is logged in or not. However, you can follow the steps mentioned below to remove the title once user has logged in:
1. Open “wp-content/plugins/loginradius-for-wordpress/LoginRadius_widget.php” in your favorite code editor.
2. Search following code (at line number 22):if( !empty( $instance[‘title’] ) ){
3. Replace the code searched above with following:
if( !empty( $instance[‘title’] ) && ! is_user_logged_in() ){
4. Save the file back. Replace existing file, if prompted.
Hope this helps!
its not the widget title i am worried about.. my question was in regards to the social media buttons still showing even after i had authenticated (instead of showing my avatar picture and name)
Hi RolandOfEld,
We visited your website but could not find the issue. However, if you tell us which caching plugin are you using at your website, we can check it at our end.
i am using w3 total cache
any update on this? i am sometimes having to click 2 times on a social login button to be logged into my site (the first time it goes through the authentication method but doesnt show me as logged in)
Hi,
Please follow the steps mentioned below to resolve the issue:
1. Open “wp-content/plugins/loginradius-for-wordpress/LoginRadius.php” file in your favorite code editor.
2. Search following code (around line number 62):`if ( !is_user_logged_in() ) {
login_radius_login_script();
}`3. Place following code below the code searched above:
` ?>
<script type=”text/javascript”>
function loginRadiusAjaxGetUserStatus(){
jQuery.ajax({
type : “GET”,
url : “index.php”,
data : { loginradius_action : “get_user_status” },
dataType : ‘json’,
success : function(response){
if(response.status == 1){
jQuery(“.widget_loginradius”).html(response.html);
}
}
});
}
if(typeof jQuery != ‘undefined’){
loginRadiusAjaxGetUserStatus();
}else{
// load jQuery dynamically
loginRadiusLoadJquery(‘https://code.jquery.com/jquery-latest.min.js’, function(){ loginRadiusAjaxGetUserStatus(); });
}
/**
* Load script dynamically
*/
function loginRadiusLoadJquery(url, success) {
var script = document.createElement(‘script’);
script.src = url;
var head = document.getElementsByTagName(‘head’)[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState
|| this.readyState == ‘loaded’
|| this.readyState == ‘complete’)) {
done = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
}
</script>
<?php`4. Search following code:
` global $wpdb, $loginRadiusSettings, $loginRadiusObject;
5. Place following code after the code searched above:
// AJAX request to check if user is logged in
if ( isset($_GET[‘loginradius_action’]) && $_GET[‘loginradius_action’] == ‘get_user_status’ ){
$response = array();
if ( is_user_logged_in() ) {
global $user_ID;
$response[‘status’] = 1;
$response[‘html’] = “<div style=’height:80px;width:180px’><div style=’width:63px;float:left;’>”;
$size = ’60’;
$user = get_userdata( $user_ID );
$response[‘html’] .= “<div style=’height:80px;width:180px’><div style=’width:63px;float:left;’>”;
$currentSocialId = get_user_meta( $user_ID, ‘loginradius_current_id’, true );
// hold the value of avatar option
$socialAvatar = ”;
$avatarType = ‘thumbnail’;
if ( isset( $loginRadiusSettings[‘LoginRadius_socialavatar’] ) ) {
$socialAvatar = $loginRadiusSettings[‘LoginRadius_socialavatar’];
if ( $socialAvatar == ‘largeavatar’ ) {
$avatarType = ‘picture’;
}
}
if ( $socialAvatar && ( $userAvatar = get_user_meta( $user_ID, ‘loginradius_’.$currentSocialId.’_’.$avatarType, true ) ) !== false && strlen( trim( $userAvatar ) ) > 0 ) {
$response[‘html’] .= ‘<img alt=”user social avatar” src=”‘.$userAvatar.'” height = “‘.$size.'” width = “‘.$size.'” title=”‘.$user->user_login.'” style=”border:2px solid #e7e7e7;”/>’;
}elseif ( $socialAvatar && ( $userAvatar = get_user_meta( $user_ID, ‘loginradius_’ . $avatarType, true ) ) !== false && strlen( trim( $userAvatar ) ) > 0 ) {
$response[‘html’] .= ‘<img alt=”user social avatar” src=”‘.$userAvatar.'” height = “‘.$size.'” width = “‘.$size.'” title=”‘.$user->user_login.'” style=”border:2px solid #e7e7e7;”/>’;
}else {
$response[‘html’] .= @get_avatar( $user_ID, $size, $default, $alt );
}
$response[‘html’] .= “</div><div style=’width:100px; float:left; margin-left:10px’>”;
// username separator
if ( ! isset( $loginRadiusSettings[‘username_separator’] ) || $loginRadiusSettings[‘username_separator’] == ‘dash’ ) {
$response[‘html’] .= $user->user_login;
}elseif ( isset( $loginRadiusSettings[‘username_separator’] ) && $loginRadiusSettings[‘username_separator’] == ‘dot’ ) {
$response[‘html’] .= str_replace( ‘-‘, ‘.’, $user->user_login );
}else {
$response[‘html’] .= str_replace( ‘-‘, ‘ ‘, $user->user_login );
}
if ( $loginRadiusSettings[‘LoginRadius_loutRedirect’] == ‘custom’ && ! empty( $loginRadiusSettings[‘custom_loutRedirect’] ) ) {
$redirect = htmlspecialchars( $loginRadiusSettings[‘custom_loutRedirect’] );
}else {
$redirect = home_url();
}
$response[‘html’] .= ‘<br/><a href=”‘. wp_logout_url( $redirect ) .'”>’. __( ‘Log Out’, ‘LoginRadius’ ) .'</a></div></div>’;
}else {
$response[‘status’] = 0;
}
echo json_encode($response);
die();
}`6. Save the file back. Replace existing file, if prompted.
Hope this helps!
hi
either i am copying and pasting wrong or there is some error in the above code as after// load jQuery dynamically
the rest of the code is commented outcan you please check the code above.. as your backticks are not working either .. or use pastebin.com
thanks
Hi,
Please follow the steps mentioned below to resolve the issue:
1. Open “wp-content/plugins/loginradius-for-wordpress/LoginRadius.php” file in your favorite code editor.
2. Search following code (around line number 62):if ( !is_user_logged_in() ) { login_radius_login_script(); }
3. Place following code below the code searched above:
?> <script type="text/javascript"> function loginRadiusAjaxGetUserStatus(){ jQuery.ajax({ type : "GET", url : "index.php", data : { loginradius_action : "get_user_status" }, dataType : 'json', success : function(response){ if(response.status == 1){ jQuery(".widget_loginradius").html(response.html); } } }); } if(typeof jQuery != 'undefined'){ loginRadiusAjaxGetUserStatus(); }else{ // load jQuery dynamically loginRadiusLoadJquery('https://code.jquery.com/jquery-latest.min.js', function(){ loginRadiusAjaxGetUserStatus(); }); } /** * Load script dynamically */ function loginRadiusLoadJquery(url, success) { var script = document.createElement('script'); script.src = url; var head = document.getElementsByTagName('head')[0], done = false; // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { done = true; success(); script.onload = script.onreadystatechange = null; head.removeChild(script); } }; head.appendChild(script); } </script> <?php
4. Search following code:`
global $wpdb, $loginRadiusSettings, $loginRadiusObject;`5. Place following code after the code searched above:
// AJAX request to check if user is logged in if ( isset($_GET['loginradius_action']) && $_GET['loginradius_action'] == 'get_user_status' ){ $response = array(); if ( is_user_logged_in() ) { global $user_ID; $response['status'] = 1; $response['html'] = "<div style='height:80px;width:180px'><div style='width:63px;float:left;'>"; $size = '60'; $user = get_userdata( $user_ID ); $response['html'] .= "<div style='height:80px;width:180px'><div style='width:63px;float:left;'>"; $currentSocialId = get_user_meta( $user_ID, 'loginradius_current_id', true ); // hold the value of avatar option $socialAvatar = ''; $avatarType = 'thumbnail'; if ( isset( $loginRadiusSettings['LoginRadius_socialavatar'] ) ) { $socialAvatar = $loginRadiusSettings['LoginRadius_socialavatar']; if ( $socialAvatar == 'largeavatar' ) { $avatarType = 'picture'; } } if ( $socialAvatar && ( $userAvatar = get_user_meta( $user_ID, 'loginradius_'.$currentSocialId.'_'.$avatarType, true ) ) !== false && strlen( trim( $userAvatar ) ) > 0 ) { $response['html'] .= '<img alt="user social avatar" src="'.$userAvatar.'" height = "'.$size.'" width = "'.$size.'" title="'.$user->user_login.'" style="border:2px solid #e7e7e7;"/>'; }elseif ( $socialAvatar && ( $userAvatar = get_user_meta( $user_ID, 'loginradius_' . $avatarType, true ) ) !== false && strlen( trim( $userAvatar ) ) > 0 ) { $response['html'] .= '<img alt="user social avatar" src="'.$userAvatar.'" height = "'.$size.'" width = "'.$size.'" title="'.$user->user_login.'" style="border:2px solid #e7e7e7;"/>'; }else { $response['html'] .= @get_avatar( $user_ID, $size, $default, $alt ); } $response['html'] .= "</div><div style='width:100px; float:left; margin-left:10px'>"; // username separator if ( ! isset( $loginRadiusSettings['username_separator'] ) || $loginRadiusSettings['username_separator'] == 'dash' ) { $response['html'] .= $user->user_login; }elseif ( isset( $loginRadiusSettings['username_separator'] ) && $loginRadiusSettings['username_separator'] == 'dot' ) { $response['html'] .= str_replace( '-', '.', $user->user_login ); }else { $response['html'] .= str_replace( '-', ' ', $user->user_login ); } if ( $loginRadiusSettings['LoginRadius_loutRedirect'] == 'custom' && ! empty( $loginRadiusSettings['custom_loutRedirect'] ) ) { $redirect = htmlspecialchars( $loginRadiusSettings['custom_loutRedirect'] ); }else { $redirect = home_url(); } $response['html'] .= '<br/><a href="'. wp_logout_url( $redirect ) .'">'. __( 'Log Out', 'LoginRadius' ) .'</a></div></div>'; }else { $response['status'] = 0; } echo json_encode($response); die(); }
6. Save the file back. Replace existing file, if prompted.
Hope this helps!
this worked!! thanks a lot
- The topic ‘shortcode and caching questions’ is closed to new replies.