diff --git a/user_relationship_mailer/user_relationship_mailer.module b/user_relationship_mailer/user_relationship_mailer.module
index 8589c8f..17d1f97 100644
--- a/user_relationship_mailer/user_relationship_mailer.module
+++ b/user_relationship_mailer/user_relationship_mailer.module
@@ -36,8 +36,8 @@ function user_relationship_mailer_send_email($op, $relationship) {
   $relationship->requester = $requester = user_load($relationship->requester_id);
   $relationship->requestee = $requestee = user_load($relationship->requestee_id);
 
-  $send_to_requestee = isset($requestee->user_relationship_mailer_send_mail) ? $requestee->user_relationship_mailer_send_mail : TRUE;
-  $send_to_requester = isset($requester->user_relationship_mailer_send_mail) ? $requester->user_relationship_mailer_send_mail : TRUE;
+  $send_to_requestee = isset($requestee->data['user_relationship_mailer_send_mail']) ? $requestee->data['user_relationship_mailer_send_mail'] : TRUE;
+  $send_to_requester = isset($requester->data['user_relationship_mailer_send_mail']) ? $requester->data['user_relationship_mailer_send_mail'] : TRUE;
 
   $send_to = array();
   switch ($op) {
@@ -190,7 +190,7 @@ function user_relationship_mailer_form_alter(&$form, &$form_state, $form_id) {
     $form['user_relationships_ui_settings']['user_relationship_mailer_send_mail'] = array(
       '#type'           => 'checkbox',
       '#title'          => t('Receive e-mail notification of relationship activity'),
-      '#default_value'  => isset($form['#user']->user_relationship_mailer_send_mail) ? $form['#user']->user_relationship_mailer_send_mail : TRUE,
+      '#default_value'  => isset($form['#user']->data['user_relationship_mailer_send_mail']) ? $form['#user']->data['user_relationship_mailer_send_mail'] : TRUE,
       '#description'    => t("If checked, we will e-mail you when there are changes to your relationship status with other users."),
       '#weight'         => -10,
       '#access' => $access,
@@ -198,3 +198,10 @@ function user_relationship_mailer_form_alter(&$form, &$form_state, $form_id) {
   }
 }
 
+/**
+ * Implements hook_user_presave().
+ */
+function user_relationship_mailer_user_presave(&$edit, $account, $category) {
+  $edit['data']['user_relationship_mailer_send_mail'] = isset($edit['user_relationship_mailer_send_mail']) ? $edit['user_relationship_mailer_send_mail'] : TRUE;
+}
+
diff --git a/user_relationship_privatemsg/user_relationship_privatemsg.module b/user_relationship_privatemsg/user_relationship_privatemsg.module
index 74980cf..3a8f0a3 100644
--- a/user_relationship_privatemsg/user_relationship_privatemsg.module
+++ b/user_relationship_privatemsg/user_relationship_privatemsg.module
@@ -327,3 +327,10 @@ function user_relationship_privatemsg_form_alter(&$form, &$form_state, $form_id)
     }
   }
 }
+
+/**
+ * Implements hook_user_presave().
+ */
+function user_relationship_privatemsg_user_presave(&$edit, $account, $category) {
+  $edit['data']['user_relationships_allow_private_message'] = isset($edit['user_relationships_allow_private_message']) ? $edit['user_relationships_allow_private_message'] : 'on all users';
+}
diff --git a/user_relationships_ui/user_relationships_ui.info b/user_relationships_ui/user_relationships_ui.info
index e1c66bb..6cf72f7 100644
--- a/user_relationships_ui/user_relationships_ui.info
+++ b/user_relationships_ui/user_relationships_ui.info
@@ -3,3 +3,4 @@ description = "User Relationships UI. This enables basic UI functionality for Us
 package = "User Relationships"
 dependencies[] = user_relationships
 core = 7.x
+files[]=user_relationships_ui.test
diff --git a/user_relationships_ui/user_relationships_ui.module b/user_relationships_ui/user_relationships_ui.module
index 3d9de09..350b06a 100644
--- a/user_relationships_ui/user_relationships_ui.module
+++ b/user_relationships_ui/user_relationships_ui.module
@@ -497,29 +497,23 @@ function user_relationships_ui_form_alter(&$form, &$form_state, $form_id) {
 
         $options = array();
         foreach ($relationships as $relationship) {
-          if ($relationship->requires_approval) {
+          if ($relationship->requires_approval && user_relationships_can_receive($form['#user'], $relationship)) {
             $options[$relationship->rtid] = ur_tt("user_relationships:rtid:$relationship->rtid:name", $relationship->name);
           }
         }
 
         //#453090 Do nothing if there are no options.
         if (count($options)) {
-
-        $form['user_relationships_ui_settings']['user_relationships_ui_auto_approve'] = array(
-          '#type'           => 'checkboxes',
-          '#title'          => t('Automatically approve relationship requests from other users'),
-          '#options'        => $options,
-          '#default_value'  => $form['#user']->data['user_relationships_ui_auto_approve'],
-          '#description'    => t("When another user requests a relationship with you, we usually require your approval. If you'd like certain relationship types to be approved automatically, check the box next to that type.")
-        );
+          $form['user_relationships_ui_settings']['user_relationships_ui_auto_approve'] = array(
+            '#type'           => 'checkboxes',
+            '#title'          => t('Automatically approve relationship requests from other users'),
+            '#options'        => $options,
+            '#default_value'  => $form['#user']->data['user_relationships_ui_auto_approve'],
+            '#description'    => t("When another user requests a relationship with you, we usually require your approval. If you'd like certain relationship types to be approved automatically, check the box next to that type.")
+          );
         }
       }
     }
-
-    // No options have been set so don't display it
-    if (isset($form['user_relationships_ui_settings']) && sizeof($form['user_relationships_ui_settings']) == 3) {
-      unset($form['user_relationships_ui_settings']);
-    }
   }
 }
 
@@ -527,9 +521,14 @@ function user_relationships_ui_form_alter(&$form, &$form_state, $form_id) {
  * Hides the settings fieldset if there are no options to be displayed.
  */
 function user_relationships_ui_account_fieldset_remove_if_empty($element) {
-  if (count(element_children($element)) == 0) {
-    $element['#access'] = FALSE;
+  // Go through all child elements, if any of them is visible, do not hide.
+  // If no elements exist or none are accessible, hide this element.
+  foreach (element_children($element) as $key) {
+    if (!isset($element[$key]['#access'])  || $element[$key]['#access']) {
+      return $element;
+    }
   }
+  $element['#access'] = FALSE;
   return $element;
 }
 
@@ -538,7 +537,6 @@ function user_relationships_ui_account_fieldset_remove_if_empty($element) {
  */
 function user_relationships_ui_user_presave(&$edit, $account, $category) {
   $edit['data']['user_relationships_ui_auto_approve'] = isset($edit['user_relationships_ui_auto_approve']) ? $edit['user_relationships_ui_auto_approve'] : array();
-  $edit['data']['user_relationships_allow_private_message'] = isset($edit['user_relationships_allow_private_message']) ? $edit['user_relationships_allow_private_message'] : array();
 }
 
 /**
diff --git a/user_relationships_ui/user_relationships_ui.test b/user_relationships_ui/user_relationships_ui.test
new file mode 100644
index 0000000..614a9a5
--- /dev/null
+++ b/user_relationships_ui/user_relationships_ui.test
@@ -0,0 +1,192 @@
+<?php
+
+/**
+ * @file
+ * User Relationships UI tests
+ */
+
+/**
+ * Tests for user settings.
+ */
+class UserRelationshipUserSettings extends DrupalWebTestCase {
+  /**
+   * Implements getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('User Relationships User settings'),
+      'description' => t('Check if user settings work as expected.'),
+      'group' => t('User Relationships'),
+    );
+  }
+
+  /**
+   * Set up the test case.
+   */
+  function setUp() {
+    parent::setUp(array('user_relationships', 'user_relationships_ui', 'user_relationship_mailer'));
+
+    // Create relationship types.
+    $rtype = new StdClass;
+    $rtype->name = 'oneway';
+    $rtype->plural_name = 'oneways';
+    $rtype->is_oneway = TRUE;
+    $rtype->requires_approval = FALSE;
+    $rtype->expires_val = 0;
+    user_relationships_type_save($rtype);
+    $this->rtypes['oneway'] = $rtype;
+
+    $rtype = new StdClass;
+    $rtype->name = 'twoway';
+    $rtype->plural_name = 'twoways';
+    $rtype->is_oneway = FALSE;
+    $rtype->requires_approval = FALSE;
+    $rtype->expires_val = 0;
+    user_relationships_type_save($rtype);
+    $this->rtypes['twoway'] = $rtype;
+
+    unset($rtype);
+    $rtype = new StdClass;
+    $rtype->name = 'approval';
+    $rtype->plural_name = 'approvals';
+    $rtype->is_oneway = FALSE;
+    $rtype->requires_approval = TRUE;
+    $rtype->expires_val = 0;
+    user_relationships_type_save($rtype);
+    $this->rtypes['approval'] = $rtype;
+
+    unset($rtype);
+    $rtype = new StdClass;
+    $rtype->name = 'approval-oneway';
+    $rtype->plural_name = 'approvals-oneway';
+    $rtype->is_oneway = TRUE;
+    $rtype->requires_approval = TRUE;
+    $rtype->expires_val = 0;
+    user_relationships_type_save($rtype);
+    $this->rtypes['approval-oneway'] = $rtype;
+
+    user_relationships_types_load(TRUE);
+
+    // Allow users to auto approve relationships.
+    variable_set('user_relationships_allow_auto_approve', TRUE);
+
+    // Allow users to disable e-mail notifications.
+    variable_set('user_relationship_mailer_send_mail', TRUE);
+
+    // Flush permission cache.
+    user_relationships_types_load(TRUE);
+    $this->checkPermissions(array(), TRUE);
+  }
+
+  /**
+   * Test the various user settings.
+   */
+  function testAutoApprovalSettings() {
+     $permissions = array(
+      'can have ' . $this->rtypes['oneway']->name . ' relationships',
+      'can request ' . $this->rtypes['oneway']->name . ' relationships',
+      'can have ' . $this->rtypes['twoway']->name . ' relationships',
+      'can request ' . $this->rtypes['twoway']->name . ' relationships',
+      'view user relationships',
+    );
+    // User without maintain permission.
+    $u1 = $this->drupalCreateUser($permissions);
+
+    // User without permission for an approval relationship.
+    $permissions[] = 'maintain own relationships';
+    $u2 = $this->drupalCreateUser($permissions);
+
+    // Two users with all required permissions.
+    $permissions[] = 'can have ' . $this->rtypes['approval-oneway']->name . ' relationships';
+    $permissions[] =  'can request ' . $this->rtypes['approval-oneway']->name . ' relationships';
+    $permissions[] =  'can have ' . $this->rtypes['approval']->name . ' relationships';
+    $permissions[] =  'can request ' . $this->rtypes['approval']->name . ' relationships';
+    $u3 = $this->drupalCreateUser($permissions);
+    $u4 = $this->drupalCreateUser($permissions);
+
+    // First user does not have maintain permission, should not see any
+    // Relationships options.
+    $this->drupalLogin($u1);
+    $this->drupalGet('user/' . $u1->uid . '/edit');
+    $this->assertNoText(t('Automatically approve relationship requests from other users'));
+    $this->assertNoText(t('Receive e-mail notification of relationship activity'));
+
+    // Make sure that there is no empty relationship fieldset.
+    // Because the relationships tab is always there, use unique text to ensure
+    // that no other text like this is present.
+    // @todo: Find a better way to deal with this.
+    $this->assertUniqueText(T('Relationship'));
+
+    // Second user is not allowed to have relationships of types which require
+    // approval, no options should be displayed. He is however allowed to
+    // disable e-mail notifications.
+    $this->drupalLogin($u2);
+    $this->drupalGet('user/' . $u2->uid . '/edit');
+    $this->assertNoText(t('Automatically approve relationship requests from other users'));
+    $this->assertText(t('Receive e-mail notification of relationship activity'));
+
+    // Disable e-mail notifications of this user.
+    $edit = array(
+     'user_relationship_mailer_send_mail' => FALSE,
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+
+    // The third user is allowed to see the settings, but only for the types
+    // which require approval
+    $this->drupalLogin($u3);
+    $this->drupalGet('user/' . $u3->uid . '/edit');
+    $this->assertText(t('Automatically approve relationship requests from other users'));
+    $this->assertText(t('Receive e-mail notification of relationship activity'));
+    $this->assertFieldByName('user_relationships_ui_auto_approve[' . $this->rtypes['approval']->rtid . ']');
+    $this->assertFieldByName('user_relationships_ui_auto_approve[' . $this->rtypes['approval-oneway']->rtid . ']');
+    $this->assertNoFieldByName('user_relationships_ui_auto_approve[' . $this->rtypes['oneway']->rtid . ']');
+    $this->assertNoFieldByName('user_relationships_ui_auto_approve[' . $this->rtypes['twoway']->rtid . ']');
+
+    // Enable auto approval for the approval-oneway type.
+    $edit = array(
+      'user_relationships_ui_auto_approve[' . $this->rtypes['approval-oneway']->rtid . ']' => TRUE,
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+
+    // Verify that the defaults are set correctly.
+    $this->assertFieldChecked('edit-user-relationships-ui-auto-approve-' . $this->rtypes['approval-oneway']->rtid);
+    $this->assertNoFieldChecked('edit-user-relationships-ui-auto-approve-' . $this->rtypes['approval']->rtid);
+
+    // Finally, actually verify that the settings work.
+    $this->drupalLogin($u4);
+
+    // Request approval relationship, should not approve automatically.
+    $this->drupalPost('relationship/' . $u3->uid . '/request/' . $this->rtypes['approval']->rtid, array(), t('Send'));
+    $this->assertText(t('Your approval request has been sent to @user.', array('@user' => $u3->name)));
+
+    // Request approval-oneway relationships, should approve automatically.
+    $this->drupalPost('relationship/' . $u3->uid . '/request/' . $this->rtypes['approval-oneway']->rtid, array(), t('Send'));
+    $this->assertText(t("You are @user's newest approval-oneway.", array('@user' => $u3->name)));
+
+    // Load relationships between these two users.
+    $relationships = user_relationships_load(array('between' => array($u3->uid, $u4->uid)));
+    $this->assertEqual(count($relationships), 2);
+    foreach ($relationships as $relationship) {
+      if ($relationship->rtid == $this->rtypes['approval-oneway']->rtid) {
+        $this->assertTrue((bool)$relationship->approved);
+      }
+      elseif ($relationship->rtid == $this->rtypes['approval']->rtid) {
+        $this->assertFalse((bool)$relationship->approved);
+      }
+      else {
+        $this->fail('Unexpected relationship type @type' , array('@type' => $relationship->rtid));
+      }
+    }
+
+    // Verify that two mails have been sent.
+    $this->assertEqual(count($this->drupalGetMails()), 2);
+
+    // Request a oneway relationship with user 2, this should not generate a
+    // mail notification.
+    $this->drupalPost('relationship/' . $u2->uid . '/request/' . $this->rtypes['oneway']->rtid, array(), t('Send'));
+    $this->assertText(t("You are @user's newest oneway.", array('@user' => $u2->name)));
+
+    // Verify that no additional mails have been sent.
+    $this->assertEqual(count($this->drupalGetMails()), 2);
+  }
+}
