Receive content follow-up notification e-mails option missing if users don't have permission to create nodes for most recent content type created on the site.

Created on 21 October 2020, about 4 years ago
Updated 13 October 2023, about 1 year ago

Problem/Motivation

The option "Receive content follow-up notification e-mails", that allow authors to be notified of comments on their own post without having to comment first themselves, does not appear on a user's profile settings page if a new content type has been created which that user does not have permission to create new nodes for.

For example, a Content editor has permission to create new Article nodes. Then an Event content type is added to the site and the Content editor does not have permission to create new Events.

Steps to reproduce

  1. Create a new custom content type (eg: Event).
  2. Configure a role (eg: Content editor) that can create nodes of at least one content type with comments enabled, but not the recently created content type (eg: Event).
  3. Create a user account with that role.
  4. Login as the newly created user and edit your profile.
  5. The user does not see the "Receive content follow-up notification e-mails" checkbox.

Proposed resolution

Change the required permission for receiving content follow-up notification e-mails from Administer nodes to Post comments.

Remaining tasks

  1. ✅ Submit patch 3178239-content-notification.patch
  2. ❌ Test patch
  3. ❌ Commit patch
🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇹Italy mtoscano

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪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
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    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

  • 🇺🇸United States cedewey Denver, CO
  • 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-...

Production build 0.71.5 2024