Moodle Tips: Modify the login box

Need to modify the “Your are logged in as…(Logout)” link text” that is at the top right of your Moodle site?

It usually looks like this:

The parentheses are hard coded but they can be removed without any problems as far as I have seen.

Find your weblib.php file.

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 created a class called ‘loginlogout’  which I applied to the login/logout link strings – a background color and some padding which gives the links some ‘oomph.’

Wondering what “Moodle” is?  Go to moodle.org for a primer and a friendly user community. When I get some more time, I will post more tips and tricks I have learned in my experiences working with Moodle.

Note that the modification to the login works with Moodle 1.8 and 1.9. I can’t vouch for other versions.

  • Share/Bookmark

You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or create a trackback from your own site.

There are no comments yet, be the first to say something


Leave a Reply

You must be logged in to post a comment.