diff --git a/masquerade.module b/masquerade.module
index 5c7da88..2c7e510 100644
--- a/masquerade.module
+++ b/masquerade.module
@@ -857,7 +857,8 @@ function masquerade_switch_user($uid) {
   // switch user

   watchdog('masquerade', 'User %user now masquerading as %masq_as.', array('%user' => $user->name, '%masq_as' => $new_user->name ? $new_user->name : variable_get('anonymous', t('Anonymous'))), WATCHDOG_INFO);
-  drupal_set_message(t('You are now masquerading as !masq_as.', array('!masq_as' => theme('username', array('account' => $new_user)))));
+  $messages = module_invoke_all('masquerade_message_login', $new_user);
+  drupal_set_message(end($messages));
   $user->masquerading = $new_user->uid;
   $user = $new_user;

@@ -876,7 +877,8 @@ function masquerade_switch_back_page() {
     global $user;
     $olduser = $user;
     masquerade_switch_back();
-    drupal_set_message(t('You are no longer masquerading as !masq_as and are now logged in as !user.', array('!user' => theme('username', array('account' => $user)), '!masq_as' => theme('username', array('account' => $olduser)))));
+    $messages = module_invoke_all('masquerade_message_logout', $user, $olduser);
+    drupal_set_message(end($messages));
     drupal_goto($_SERVER['HTTP_REFERER']);
   }
   else {
@@ -915,3 +917,17 @@ function masquerade_switch_back() {

   watchdog('masquerade', 'User %user no longer masquerading as %masq_as.', array('%user' => $user->name, '%masq_as' => $oldname), WATCHDOG_INFO);
 }
+
+/**
+ * Implements hook_masquerade_message_login().
+ */
+function masquerade_masquerade_message_login($new_user) {
+  return t('You are now masquerading as !masq_as.', array('!masq_as' => theme('username', array('account' => $new_user))));
+}
+
+/**
+ * Implements hook_masquerade_message_logout().
+ */
+function masquerade_masquerade_message_logout($user, $olduser) {
+  return t('You are no longer masquerading as !masq_as and are now logged in as !user.', array('!user' => theme('username', array('account' => $user)), '!masq_as' => theme('username', array('account' => $olduser))));
+}
