diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
index 93d6a28985..07a0f8f38c 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
@@ -94,7 +94,7 @@ protected function getEntityCounts() {
       'search_page' => 2,
       'shortcut' => 2,
       'shortcut_set' => 1,
-      'action' => 33,
+      'action' => 14,
       'menu' => 8,
       'path_alias' => 8,
       'taxonomy_term' => 15,
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
index b8690c2d76..0df79a2a4d 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
@@ -97,7 +97,7 @@ protected function getEntityCounts() {
       'search_page' => 2,
       'shortcut' => 6,
       'shortcut_set' => 2,
-      'action' => 27,
+      'action' => 14,
       'menu' => 7,
       'taxonomy_term' => 25,
       'taxonomy_vocabulary' => 8,
diff --git a/core/modules/user/src/RoleForm.php b/core/modules/user/src/RoleForm.php
index 34aa98e8fc..c2075d1baf 100644
--- a/core/modules/user/src/RoleForm.php
+++ b/core/modules/user/src/RoleForm.php
@@ -55,6 +55,37 @@ public function save(array $form, FormStateInterface $form_state) {
     $entity->set('label', trim($entity->label()));
     $status = $entity->save();
 
+    // Create actions but ignore the authenticated and anonymous roles.
+    if (!in_array($entity->id(), [RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID])) {
+      $type_manager = $this->entityTypeManager->getStorage('action');
+      $add_id = 'user_add_role_action.' . $entity->id();
+      if (!$type_manager->load($add_id)) {
+        $action = $type_manager->create([
+          'id' => $add_id,
+          'type' => 'user',
+          'label' => $this->t('Add the @label role to the selected users', ['@label' => $entity->label()]),
+          'configuration' => [
+            'rid' => $entity->id(),
+          ],
+          'plugin' => 'user_add_role_action',
+        ]);
+        $action->trustData()->save();
+      }
+      $remove_id = 'user_remove_role_action.' . $entity->id();
+      if (!$type_manager->load($remove_id)) {
+        $action = $type_manager->create([
+          'id' => $remove_id,
+          'type' => 'user',
+          'label' => $this->t('Remove the @label role from the selected users', ['@label' => $entity->label()]),
+          'configuration' => [
+            'rid' => $entity->id(),
+          ],
+          'plugin' => 'user_remove_role_action',
+        ]);
+        $action->trustData()->save();
+      }
+    }
+
     $edit_link = $this->entity->toLink($this->t('Edit'), 'edit-form')->toString();
     if ($status == SAVED_UPDATED) {
       $this->messenger()->addStatus($this->t('Role %label has been updated.', ['%label' => $entity->label()]));
diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
index 74650146e2..18e142e741 100644
--- a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
+++ b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\user\Functional\Views;
 
+use Drupal\system\Entity\Action;
 use Drupal\user\Entity\User;
 use Drupal\user\RoleInterface;
 use Drupal\views\Views;
@@ -43,6 +44,35 @@ public function testBulkForm() {
 
     // Create a user which actually can change users.
     $this->drupalLogin($this->drupalCreateUser(['administer users']));
+
+    // Assign a role to a user.
+    $account = $user_storage->load($this->users[0]->id());
+    $roles = user_role_names(TRUE);
+    unset($roles[RoleInterface::AUTHENTICATED_ID]);
+    $role = key($roles);
+
+    // Add actions.
+    $action = Action::create([
+      'id' => 'user_add_role_action.' . $role,
+      'type' => 'user',
+      'label' => t('Add the @label role to the selected users', ['@label' => $role]),
+      'configuration' => [
+        'rid' => $role,
+      ],
+      'plugin' => 'user_add_role_action',
+    ]);
+    $action->trustData()->save();
+    $action = Action::create([
+      'id' => 'user_remove_role_action.' . $role,
+      'type' => 'user',
+      'label' => t('Remove the @label role from the selected users', ['@label' => $role]),
+      'configuration' => [
+        'rid' => $role,
+      ],
+      'plugin' => 'user_remove_role_action',
+    ]);
+    $action->trustData()->save();
+
     $this->drupalGet('test-user-bulk-form');
     $this->assertNotEmpty($this->cssSelect('#edit-action option'));
 
@@ -54,12 +84,6 @@ public function testBulkForm() {
     $this->submitForm($edit, 'Apply to selected items');
     $this->assertSession()->pageTextContains('No users selected.');
 
-    // Assign a role to a user.
-    $account = $user_storage->load($this->users[0]->id());
-    $roles = user_role_names(TRUE);
-    unset($roles[RoleInterface::AUTHENTICATED_ID]);
-    $role = key($roles);
-
     $this->assertFalse($account->hasRole($role), 'The user currently does not have a custom role.');
     $edit = [
       'user_bulk_form[1]' => TRUE,
diff --git a/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php b/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php
index 527db24aa4..2132318b7d 100644
--- a/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php
+++ b/core/modules/user/tests/src/Kernel/UserActionConfigSchemaTest.php
@@ -5,6 +5,7 @@
 use Drupal\Tests\SchemaCheckTestTrait;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\user\Entity\Role;
+use Drupal\system\Entity\Action;
 
 /**
  * Ensures the user action for adding and removing roles have valid config
@@ -30,6 +31,28 @@ public function testValidUserActionConfigSchema() {
     $rid = strtolower($this->randomMachineName(8));
     Role::create(['id' => $rid, 'label' => $rid])->save();
 
+    // Add actions.
+    $action = Action::create([
+      'id' => 'user_add_role_action.' . $rid,
+      'type' => 'user',
+      'label' => t('Add the @label role to the selected users', ['@label' => $rid]),
+      'configuration' => [
+        'rid' => $rid,
+      ],
+      'plugin' => 'user_add_role_action',
+    ]);
+    $action->trustData()->save();
+    $action = Action::create([
+      'id' => 'user_remove_role_action.' . $rid,
+      'type' => 'user',
+      'label' => t('Remove the @label role from the selected users', ['@label' => $rid]),
+      'configuration' => [
+        'rid' => $rid,
+      ],
+      'plugin' => 'user_remove_role_action',
+    ]);
+    $action->trustData()->save();
+
     // Test user_add_role_action configuration.
     $config = $this->config('system.action.user_add_role_action.' . $rid);
     $this->assertEquals('user_add_role_action.' . $rid, $config->get('id'));
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 833cdc5be6..2d139f2c5d 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -5,7 +5,6 @@
  * Enables the user registration and login system.
  */
 
-use Drupal\Component\Assertion\Inspector;
 use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Render\PlainTextOutput;
 use Drupal\Component\Utility\Unicode;
@@ -24,7 +23,6 @@
 use Drupal\Core\Url;
 use Drupal\image\Plugin\Field\FieldType\ImageItem;
 use Drupal\filter\FilterFormatInterface;
-use Drupal\system\Entity\Action;
 use Drupal\user\Entity\Role;
 use Drupal\user\Entity\User;
 use Drupal\user\RoleInterface;
@@ -842,45 +840,6 @@ function user_role_names($membersonly = FALSE, $permission = NULL) {
   }, user_roles($membersonly, $permission));
 }
 
-/**
- * Implements hook_ENTITY_TYPE_insert() for user_role entities.
- */
-function user_user_role_insert(RoleInterface $role) {
-  // Ignore the authenticated and anonymous roles or the role is being synced.
-  if (in_array($role->id(), [RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID]) || $role->isSyncing()) {
-    return;
-  }
-
-  assert(Inspector::assertStringable($role->label()), 'Role label is expected to be a string.');
-
-  $add_id = 'user_add_role_action.' . $role->id();
-  if (!Action::load($add_id)) {
-    $action = Action::create([
-      'id' => $add_id,
-      'type' => 'user',
-      'label' => t('Add the @label role to the selected user(s)', ['@label' => $role->label()]),
-      'configuration' => [
-        'rid' => $role->id(),
-      ],
-      'plugin' => 'user_add_role_action',
-    ]);
-    $action->trustData()->save();
-  }
-  $remove_id = 'user_remove_role_action.' . $role->id();
-  if (!Action::load($remove_id)) {
-    $action = Action::create([
-      'id' => $remove_id,
-      'type' => 'user',
-      'label' => t('Remove the @label role from the selected user(s)', ['@label' => $role->label()]),
-      'configuration' => [
-        'rid' => $role->id(),
-      ],
-      'plugin' => 'user_remove_role_action',
-    ]);
-    $action->trustData()->save();
-  }
-}
-
 /**
  * Implements hook_ENTITY_TYPE_delete() for user_role entities.
  */
