General developer forum

disabling messaging in "log in as" mode

 
Picture of Patrick Scott
disabling messaging in "log in as" mode
 

hi

when I use the "Log in as" feature and thus simulated as if I'm logged in as another user, I would like the messaging system to be disabled, e.g: I don't want to be able to read or write messages to anyone.
I also don't want to get notifications of unread messages.

I managed to it by adding this to message/index.php:

if ( \core\session\manager::is_loggedinas() ) {

print_error(get_string('activityiscurrentlyhidden'));

}


the thing is, if the user i'm logged in as, has new messages, the function "message_popup_window" in lib/moodlelib.php still alerts the user of new messages.

I don't want that.

obviously I can add the above code in "message_popup_window" but I don't want to modify that core file.

I have my own moodle theme and rather do it from there if possible.
is it?

an alternative might be via css but how can I tell if the user is in "log in as" mode from the cleint side (css/js)?

I'm using moodle 3.1

 
Average of ratings: -