diff --git a/public_html/sites/all/modules/custom/features/g365_messaging_notifications/g365_messaging_notifications.module b/public_html/sites/all/modules/custom/features/g365_messaging_notifications/g365_messaging_notifications.module
index a15bdf7..a5e3e8c 100644
--- a/public_html/sites/all/modules/custom/features/g365_messaging_notifications/g365_messaging_notifications.module
+++ b/public_html/sites/all/modules/custom/features/g365_messaging_notifications/g365_messaging_notifications.module
@@ -35,6 +35,7 @@ function g365_messaging_notifications_form_alter(&$form, &$form_state, $form_id)
   if ($form_id == 'user_profile_form') {
     switch ($form['_category']['#value']) {
       case 'account';
+      dsm($form);
         // Remove the following form fields from the user account tab.
         unset($form['enable_pm_mail']); // pm_email_notify_user
         unset($form['messaging']); // messaging_user
diff --git a/public_html/sites/all/modules/privatemsg/pm_email_notify/pm_email_notify.module b/public_html/sites/all/modules/privatemsg/pm_email_notify/pm_email_notify.module
index 7cbd744..464efa5 100644
--- a/public_html/sites/all/modules/privatemsg/pm_email_notify/pm_email_notify.module
+++ b/public_html/sites/all/modules/privatemsg/pm_email_notify/pm_email_notify.module
@@ -172,15 +172,17 @@ function pm_email_notify_user($op, &$edit, &$account, $category = NULL) {
       if ($category == 'account' && privatemsg_user_access('read privatemsg')) {
         $pm_email_enabled = $edit['pm_send_notifications'];
         unset($edit['pm_send_notifications']);
-        // Update database entry with user preference.
-        $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid));
-        if ($exists) {
-          // If there is an existing entry, update.
-          db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
-        }
-        else {
-          // If not, create a new one.
-          db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
+        if (isset($pm_email_enabled)) {
+          // Update database entry with user preference.
+          $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid));
+          if ($exists) {
+            // If there is an existing entry, update.
+            db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
+          }
+          else {
+            // If not, create a new one.
+            db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
+          }
         }
       }
       break;
