- 🇩🇪Germany vgutekunst
#8 worked for me. Users see the check box now in their profile. BUT how can i set it to all users (old ones too) as active?
I also encountered the problem with non-admins not being able to see the checkbox to allow them to subscribe to notifications about comments made to their content.
I made the attached patch based on mtoscano's comment #2.
I also wanted to mark all existing users so they received notifications by default, so I wrote this hook_update_n, put it in a custom module, and ran drush updb to execute it. I had just installed the module, so I decided to delete any existing user content_notify settings and then set the settings across all users.
/**
* Set all users comment_notify to 1 for comments about their content and 2 for comments about their comments
*/
function air_utility_update_8005() {
# DELETE CURRENT ENTRIES IN users_data WHERE module like content_notify
$connection = \Drupal\Core\Database\Database::getConnection();
$num_deleted = $connection->delete('users_data')
->condition('module', 'comment_notify')
->execute();
\Drupal::logger('mymodule_notifications')->notice("Deleted comment_notify settings for ".$num_deleted." users");# LOAD DATA FOR ALL USERS
$query = \Drupal::entityQuery('user')
->condition('status', 1)
->sort('uid');
$uids = $query->execute();\Drupal::logger('mymodule_notifications')->notice("Loaded all users");
# LOOP THROUGH USERS AND SET DEAFULT FOR entity_notify and comment_notify
$counter = 1;
$count_users = count($uids);
foreach ($uids as $thisuid => $user) {
\Drupal::logger('mymodule_notifications')->notice("Start update for user(".$counter." of ".$count_users."): ".$thisuid."");
$counter++;
$result = $connection->insert('users_data')
->fields([
'uid' => $thisuid,
'module' => 'comment_notify',
'name' => 'entity_notify',
'value' => 1,
'serialized' => 0,
])
->execute();
$result2 = $connection->insert('users_data')
->fields([
'uid' => $thisuid,
'module' => 'comment_notify',
'name' => 'comment_notify',
'value' => 2,
'serialized' => 0,
])
->execute();
} # END FOREACH LOOP
}- Status changed to Needs review
about 1 year ago 3:20pm 6 October 2023 - last update
about 1 year ago 15 pass - 🇺🇸United States cedewey Denver, CO
Hi all,
I've updated the issue title and summary with my best understanding of the situation.
I believe that davidhk is correct in comment #9 that this is not an issue with the wrong permission being required to see the "Receive content follow-up notification e-mails" checkbox, but rather that the code is not looping through the whole array of entities with commenting enabled.
I configured the Content editor role to not have the "Administer content" permission and registered a new user account with the Content editor role. I saw the "Receive content follow-up notification emails" checkbox as expected.
However, when I created a new content type (Event) and did not grant the Content editor role permission to create new Event nodes, the "Receive content follow-up notification e-mails" checkbox no longer appeared on their profile edit page.
If I then grant them the permission "Event: Create new content" the checkbox then appears again on their profile page as expected.
I've created a patch based on davidhk's work and tested it and it fixes the issue. Marking this as needs review. If it ends up approved, maintainers please give davidhk author credit for this patch. :D
- Assigned to gnuget
- 🇺🇸United States cedewey Denver, CO
Escalating this to a major issue, since it "Interfere with normal site visitors' use of the site." See https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-... →