Need to modify the "Your are logged in as...(Logout)" link text
For reason of authentication, I need to remove the "(Logout)" string at the end of the "You are logged in as foo.bar (Logout)" string in the header and footer.
Can someone please point me to where I can make the change? Moodle seems to generate this in the context variable $menu, but I can't seem to find where this is defined in order to remove this (Logout).
Thanks,
Fred
ps: I need to remove the "Logout" given a custom SSO plug-in, to avoid confusing the user...
Re: Need to modify the "Your are logged in as...(Logout)" link text
In this case, the parenthesis around the logout string are hard-coded, and the string doesn't have an id or classname, so you can't use css to hide just the '(Logout)' part.
You can hide the entire 'You are logged in as...' string by adding this to your theme's stylesheet -
.logininfo {
display: none;
}
(Note that you'll need to provide some other way for users to get to their profiles.)
Or, you can edit the code in lib/weblib.php, on about line 3442, in user_login_string() (1.9.2+):
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).' '.
" (<a $CFG->frametarget href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
Comment out the above line and add the following:
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username);
Re: Need to modify the "Your are logged in as...(Logout)" link text
Thanks for the useful info Ann. I am trying to style the login elements described above. Specifically I would like to put the Login and Logout pieces of text onto the line below the lines 'You are not logged in.' and 'You are logged in as: Name'.
However, both pieces of text appear as links within the div.logininfo. Neither of these links have ids so I don't think this is possible with CSS (I have just tried for several hours!).
I can't target them with CSS selectors because when the logout link is displayed it is the second <a> element within the div.logininfo.
In order to target them am I right in thinking someone will have to add ids into a PHP file somewhere?
Any info or help would be appreciated.
~thomas
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Do this for all the code that refers to 'login,' 'logout,' 'switchrolereturn,' and 'loggedinas'
In my weblib.php this runs from lines 3477 to 3497
Remove the ( that occurs after the " and the ) that is just before the last ';
Original:
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
" (<a $CFG->frametarget href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
After:
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
" <a $CFG->frametarget href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>';
2) To put a line break between login status (ie "You are logged in as..." or "You are not logged in.") and the 'login' link, you can add two br tags and appropriate php code:
For example, to make a line break between the 'logged in as' text and the 'logout' link, do the following:
Before:
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
" <a $CFG->frametarget href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>';
After:
$loggedinas = get_string('loggedinnot', 'moodle').
'<br><br>' . " <a $CFG->frametarget href=\"$wwwroot/login/index.php\">".get_string('login').'</a>';
}
Again, you can do this to all the code that refers to 'login,' 'logout,' 'switchrolereturn,' and 'loggedinas' to keep everything looking uniform.
BE VERY CAREFUL when editing. Remove the wrong parenthesis or forget to add a '. and you probably don't need me to warn you of how that will mess up your site.
Hope this helps you!
I have also been able to add style tags to my theme's css and then apply them to the php strings for 'login' and 'logout.' I didn't want to put that on here too as I know this all can be confusing enough. Feel free to message me if you have more questions about this, thanks!
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Many thanks for your very helpful explanation. Everything works as you have described it.
I am trying now to hide the text: 'you are logged in as' and 'you are not logged in'. feel that this text is redundant. I would like Moodle just to show:
Login (when user is not logged in)
and
Username Logout (when user is logged in)
I have tried language editing: leaving an empty string but Moodle detects this. Whilst writing this post I had an idea to use a HTML character entity for a space  
This actually does trick Moodle but is a horrible hack! I do not know anything much about PHP at all (I am an XHTML/CSS developer). Is there a way to address the PHP variable 'loggedinnot' using CSS? I would then set it to display: none; using CSS.
Is this what you meant when you wrote:
I have also been able to add style tags to my theme's css and then apply them to the php strings for 'login' and 'logout.'
Any advice on how to do this would be appreciated.
Many thanks
~thomas
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
I presume you are looking for a hook? You can add a <span> with a class name where the double line break is above with out any problems. You wont be able to select a string with CSS across all browsers.
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hi Stephen,
Many thanks for the info. So you can select a PHP string with CSS? Any pointers on how to do this would be appreciated. I am just curious how this works (and in which browsers it doesn't work!
~thomas
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
So in stead of using this new adaption:
$loggedinas = get_string('loggedinnot', 'moodle').
'<br><br>' . " <a $CFG->frametarget href=\"$wwwroot/login/index.php\">".get_string('login').'</a>';
}
you would use
$loggedinas = get_string('loggedinnot', 'moodle').
'<span class=\"someClass\">' . " <a $CFG->frametarget href=\"$wwwroot/login/index.php\">".get_string('login').'</a></span>';
}
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hi Stephen,
Thanks for the clarification. I guess this is what May also meant. Whereas I was complexifying things by imagining that you could directly access PHP variables from CSS.
~thomas
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
I have another issue though.
A client has asked us to move the loginifro string below the nav bar...
any ideas on how to do this?
Thanks!
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
That's if I am reading your request correctly?
Mary
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Mary
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Have a look at Themes_FAQ#Moving_things for some ideas, especially at http://moodle.org/mod/forum/discuss.php?d=128599
hth
Frank
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hello everybody,
I'm using the standard theme on my site. I already have a logo on the header, but i want it to expand horizontally 100%,. if i do that the "you are logged in as.." will be blocked or not visualized.
there is a thin black line below the logoon standard theme, and my question is. can i move the login info section below the line on the right side.
Thanks
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Moodle 1.9 Themes FAQ
Moodle 2.0 Themes 2.0 FAQ
You can achive quite a bit when customising themes using CSS FAQ
Mary
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hi everybody,
I'm trying to do the same thing, would you please tell which file from the language package do I have to edit to remove the "you are now logged in as" message.
Thank you!
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
If you want to remove the message from your page, then I would suggest using css to hide it rather than deleting/editing it in the language pack as that would affect every theme on your site.
Off the top of my head (so you may need to check this yourself) I think its
.logininfo {display:none;}
but I can't remember whether its .logininfo or #logininfo (whether its a class or an id selector). You'd need to add this line to the end of your main css file in the theme - or on the customcss box of the theme's settings page if it has one.
HTH
Richard
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hi Thomas,
Could you please tell how did you do that, I mean which file did you modify.
I've been trying to find it in the language editor with no success.
Thank you in advance,
Miguel S.
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
moodle/lang/en/moodle.php
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Thank you Mary,
It was just right there.
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hi Miguel,
Just to be clear, this was an issue for me in Moodle 1.9. Our site has now moved to Moodle 2 and a theme which I based on the Aardvark theme. So if you were using Moodle 2 and Aardvark the hack below is not needed. I have pasted in notes I made at the time though in case you are using 1.9 and if so they may help.
To change the text: “You are logged in as” you need to edit the language files and the weblib.php
Language files:
Admin ->Language ->Language Editing ->Moodle.php
If you try to remove the text: ‘”you are not logged in” from the language file ie. leave a blank string then Moodle will detect this and prevent you from doing so, with a blank string error message.
To remove the text you have to remove the call to write this text out from within weblib.php
Weblib.php
Location is: /web/lib/weblib.php within your Moodle directory structure.
...as described in the above posts.
Hope this helps.
~t
Re: Need to modify the "Your are logged in as...(Logout)" link text - Here is a solution
Hi Thomas,
Thank you very much for taking the time to explain me all this, it also worked as you said, especially in the case of leaving it blank.
Thank you very much!
Miguel S.
Odp: Re: Need to modify the "Your are logged in as...(Logout)" link text
In Moodle 2.3+ you can find lines
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).' '.
" (<a $CFG->frametarget href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
in \lib\outputrenders.php file, on about line 486.
Re: Odp: Re: Need to modify the "Your are logged in as...(Logout)" link text
That is useful to know thanks!