Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VOTE-1987: Add custom module to block site_builders on production. #975

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/production/config_split.patch.core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ adding:
s3fs: 0
samlauth: 0
usagov_login: 0
vote_users: 0
externalauth: 10
removing: { }
5 changes: 5 additions & 0 deletions web/modules/custom/vote_users/vote_users.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Vote Users'
type: module
description: 'Provides custom handling of user accounts.'
core_version_requirement: ^10 || ^11
package: Custom
23 changes: 23 additions & 0 deletions web/modules/custom/vote_users/vote_users.install
daniel-crowder marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
use Drupal\user\Entity\User;


/**
* Implements hook_install().
*/
function vote_users_install() {
// Get all users who have the site_builder role.
$users = \Drupal::entityQuery('user')
->accessCheck(FALSE)
->condition('roles', 'site_builder')
->execute();

// Block all users who match the criteria above.
foreach ($users as $user_id) {
$user = User::load($user_id);
if ($user) {
$user->block();
$user->save();
}
}
}