var user_seems_to_be_logged_in = false; var loggedInUsername = ''; var loggedInHTML =' ' ; var loggedOutHTML =' '; var loginStatusHTML = ''; /* time to document.write the appropriate variable in place */ var MHK = false; var storedTime = 1000 * blp_getInBetween('','|','|'); var rightNow = Number(new Date()); var difInTime=storedTime-rightNow; //// alert("difInTime:" + difInTime); // when the actual login expired, the diffIntime is a minus! // that's the most definitive clue about the login status! ////alert("BEFORE user_seems_to_be_logged_in ( this could be misleading when cookie expires!) : "+user_seems_to_be_logged_in); if ( difInTime < 0 ){ user_seems_to_be_logged_in = false; } ////alert("AFTER user_seems_to_be_logged_in ( & this is always reliable): "+user_seems_to_be_logged_in); if ( user_seems_to_be_logged_in ){ //user seems be logged in loggedInHTML = loggedInHTML.replace('[username]',loggedInUsername, loggedInHTML); //special treatment to admin! if admin logs in, send him to /wp-admin if ( loggedInUsername.indexOf("Admin") !== -1 ) { // this is admin - replace the [path] as /wp-admin loggedInHTML = loggedInHTML.replace('[path]','/wp-admin', loggedInHTML); } else { // this is normal user - replace the [path] as /profile loggedInHTML = loggedInHTML.replace('[path]','/profile', loggedInHTML); } loginStatusHTML = loggedInHTML; } else { // user seems to be NOT logged_in // this is normal user & not logged in. replace the [path] as /login loggedOutHTML = loggedOutHTML.replace('[path]','/login', loggedInHTML); loginStatusHTML = loggedOutHTML; } var blpjs_username; // used in determining if a user logged in or not as well as who logged in. Ex: 'Admin' used ny overwriting-scripts.js if ( user_seems_to_be_logged_in ){ //user seems be logged in blpjs_username = loggedInUsername; } else { // user seems to be NOT logged_in blpjs_username = ''; // empty string means not logged in }