diff --git a/message/output/popup/tests/behat/message_popover_unread.feature b/message/output/popup/tests/behat/message_popover_unread.feature
index ebd93b25bd4..9706aa9e95a 100644
--- a/message/output/popup/tests/behat/message_popover_unread.feature
+++ b/message/output/popup/tests/behat/message_popover_unread.feature
@@ -16,6 +16,9 @@ Feature: Message popover unread messages
       | user     | course | role           |
       | student1 | C1     | student        |
       | student2 | C1     | student        |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "student2"
     And I send "Test message" message to "Student 1" user
     And I log out
diff --git a/message/tests/behat/delete_all_messages.feature b/message/tests/behat/delete_all_messages.feature
index a1ba0325464..2aa7b26ecbc 100644
--- a/message/tests/behat/delete_all_messages.feature
+++ b/message/tests/behat/delete_all_messages.feature
@@ -16,6 +16,9 @@ Feature: Delete all messages
       | user     | course | role        |
       | user1    | C1     | student     |
       | user2    | C1     | student     |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "user2"
     And I send "User 2 to User 1 message 1" message to "User 1" user
     And I send "User 2 to User 1 message 2" message in the message area
diff --git a/message/tests/behat/delete_messages.feature b/message/tests/behat/delete_messages.feature
index 07559d167f7..ec21545ff3b 100644
--- a/message/tests/behat/delete_messages.feature
+++ b/message/tests/behat/delete_messages.feature
@@ -16,6 +16,9 @@ Feature: Delete messages
       | user     | course | role           |
       | user1    | C1     | student        |
       | user2    | C1     | student        |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "user2"
     And I send "User 2 to User 1 message 1" message to "User 1" user
     And I send "User 2 to User 1 message 2" message in the message area
diff --git a/message/tests/behat/manage_contacts.feature b/message/tests/behat/manage_contacts.feature
index b3d142c84e8..278b115de05 100644
--- a/message/tests/behat/manage_contacts.feature
+++ b/message/tests/behat/manage_contacts.feature
@@ -10,6 +10,9 @@ Feature: Manage contacts
       | user1    | User      | 1        | user1@example.com    |
       | user2    | User      | 2        | user2@example.com    |
       | user3    | User      | 3        | user3@example.com    |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "admin"
     And I set the following administration settings values:
       | messagingallusers | 1 |
diff --git a/message/tests/behat/reply_message.feature b/message/tests/behat/reply_message.feature
index ce7d956e72e..5f126cb1a02 100644
--- a/message/tests/behat/reply_message.feature
+++ b/message/tests/behat/reply_message.feature
@@ -9,6 +9,9 @@ Feature: Reply message
       | username | firstname | lastname | email            |
       | user1    | User      | 1        | user1@example.com    |
       | user2    | User      | 2        | user2@example.com    |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And the following "courses" exist:
       | fullname | shortname |
       | Course 1 | C1        |
@@ -16,6 +19,9 @@ Feature: Reply message
       | user     | course | role           |
       | user1    | C1     | student        |
       | user2    | C1     | student        |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "user2"
     And I send "User 2 to User 1" message to "User 1" user
     And I log out
diff --git a/message/tests/behat/search_messages.feature b/message/tests/behat/search_messages.feature
index 841be25c049..2925860c713 100644
--- a/message/tests/behat/search_messages.feature
+++ b/message/tests/behat/search_messages.feature
@@ -18,6 +18,9 @@ Feature: Search messages
       | user1    | C1     | student        |
       | user2    | C1     | student        |
       | user3    | C1     | student        |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "user2"
     And I send "User 2 to User 1" message to "User 1" user
     And I log out
diff --git a/message/tests/behat/search_users.feature b/message/tests/behat/search_users.feature
index b808ccce6fa..74a0d495aed 100644
--- a/message/tests/behat/search_users.feature
+++ b/message/tests/behat/search_users.feature
@@ -10,6 +10,9 @@ Feature: Search users
       | user1    | User      | 1        | user1@example.com    |
       | user2    | User      | 2        | user2@example.com    |
       | user3    | User      | 3        | user3@example.com    |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
 
   Scenario: Search for single user
     When I log in as "user1"
diff --git a/message/tests/behat/update_messaging_preferences.feature b/message/tests/behat/update_messaging_preferences.feature
index bfd4c2c7cd4..6bddb3fce1b 100644
--- a/message/tests/behat/update_messaging_preferences.feature
+++ b/message/tests/behat/update_messaging_preferences.feature
@@ -8,6 +8,9 @@ Feature: Messaging preferences
     Given I log in as "admin"
     And I navigate to "Plugins > Message outputs > Manage message outputs" in site administration
     And I click on "//table[contains(@class, 'admintable')]/tbody/tr/td[contains(text(), 'Email')]/following-sibling::td[1]/a" "xpath_element"
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
 
   Scenario: Alter my message preferences
     Given I follow "Preferences" in the user menu
diff --git a/message/tests/behat/view_messages.feature b/message/tests/behat/view_messages.feature
index 5c0733cb346..30ace1501ef 100644
--- a/message/tests/behat/view_messages.feature
+++ b/message/tests/behat/view_messages.feature
@@ -18,6 +18,9 @@ Feature: View messages
       | user1    | C1     | student        |
       | user2    | C1     | student        |
       | user3    | C1     | student        |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
     And I log in as "user2"
     And I send "User 2 to User 1" message to "User 1" user
     And I log out
diff --git a/user/tests/behat/delete_users.feature b/user/tests/behat/delete_users.feature
index 53934868e8d..0eb3b97684a 100644
--- a/user/tests/behat/delete_users.feature
+++ b/user/tests/behat/delete_users.feature
@@ -20,6 +20,9 @@ Feature: Deleting users
       | user2    | C1     | student        |
       | user3    | C1     | student        |
       | user4    | C1     | student        |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
 
   @javascript
   Scenario: Deleting one user at a time
diff --git a/user/tests/behat/view_full_profile.feature b/user/tests/behat/view_full_profile.feature
index bb75a3bed11..80da7d3b124 100644
--- a/user/tests/behat/view_full_profile.feature
+++ b/user/tests/behat/view_full_profile.feature
@@ -21,6 +21,9 @@ Feature: Access to full profiles of users
       | student2 | C1 | student |
       | teacher1 | C1 | editingteacher |
       | student3 | C2 | student |
+    And the following config values are set as admin:
+      | messaging | 1 |
+      | messagingallusers | 1 |
 
   Scenario: Viewing full profiles with default settings
     When I log in as "student1"