Receive content follow-up notification e-mails option available only to admin users

Created on 21 October 2020, over 4 years ago
Updated 21 May 2023, almost 2 years ago

Hi,
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, appears in the profile edit page only if the user has admin rights.

Otherwise it does not and if the user save the profile page, he is opted out to Receive content follow-up notification e-mails, I presume because not appearing the option is it updated as unchecked.

It looks like a simple permission problem, but I cannot find the permission that control it, as the only permission available is the one that let users subscribe to comment notifications, not content notifications.

If is not a permission option, than it looks like a bug.

πŸ› Bug report
Status

Active

Version

1.2

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain 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 over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update over 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-... β†’

  • πŸ‡΅πŸ‡±Poland maksim_matuzka

    Hi everyone!
    @mtoscano, I think the root cause is incorrect array of bundles, if you debug this function _comment_notify_get_comment_enabled_bundles() you will see that only one bundle per entity type can be returned. That is why user can't see the checkbox after the new bundle was created. You can test patch https://www.drupal.org/project/comment_notify/issues/3488180#comment-158... πŸ› Enabled bundles: incorrect array from _comment_notify_get_comment_enabled_bundles() Needs work
    Thanks!

Production build 0.71.5 2024