I've set the "access notify" permissions so that only specific roles should be able to access it. However, I just noticed that when a new user creates an account there is a checkbox there "Receive email notifications of news posted to this site. Notifications are sent every 1 hour." which defaults to on!

So my primary question is how do I make it so that this option doesn't show up on user login at all? That would solve the immediate problem.

A related question would be, is it perhaps a bug that even though I have set permissions such that not all roles can access notify that the new user process allows new users to bypass that permission?

Comments

moondancerjen’s picture

I'd really like to know how to fix this too. I only wanted notify so our administrators would know when anonymous users post content.

matt2000’s picture

To be clear, the presence of that check box does not in any way override the permission. If a user registers with it checked, but they do not have a role that permits them to receive notifications, then they will not receive notifications.

To prevent the selector from appearing, you can comment out line 126 of notify module as follows:

/**
 * Implementation of hook_user().
 */
function notify_user($type, &$edit, &$user, $category = NULL) {
  switch ($type) {
    case 'delete':
      db_query('DELETE FROM {notify} WHERE uid = %d', $user->uid);
      break;
    
    case 'register':
      //return _notify_user_reg_fields();  //THIS IS LINE #126. See  // added at front <--------------------
      break;
    
    case 'insert':
      if (isset($edit['notify_decision']) && $edit['notify_decision'] == 1){
        db_query('INSERT INTO {notify} (uid, status, node, teasers, comment) VALUES (%d, %d, %d, %d, %d)', $user->uid, 1, 1, 0, 0);
        $edit['notify_decision'] = NULL;
      }
      break;
    
  }
}
matt2000’s picture

[dbl post]

matt2000’s picture

[dbl post]

matt2000’s picture

Status: Needs review » Active

[dbl post -- something must be up with drupal.org's caching or DB replication, cause I swear this didn't seem to post at first.]

matt2000’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

Since I made such a mess of this thread, I'll atone by offering this patch. It modifies the notify admin settings to allow for the registration check box to be removed.

matt2000’s picture

Title: How to prevent new accounts from turning on notify » Option to Disable Notify Status selector on Registration form
Category: support » feature
Status: Active » Needs review
flaviovs’s picture

StatusFileSize
new415 bytes

@matt2000, although your patch provides a workaround for people who don't want the checkbox on the reg form, I IMHO think this is not the best way to handle this issue.

Since we already have an 'access notify' permission, there's no need for an additional settings. Just check user_acess('access notify' ) to know if the user should be presented with the checkbox or not.

Patch attached.

matt2000’s picture

A valid point, but what about the scenario where you want to allow registered users to manage their own settings, but you don't want it as part of the registration process? I.e., all users are added to the list by default, but have the option to opt-out. Is this too rare a scenario to consider?

Michel Poulain’s picture

Hi Matt,

With your last patch, the administrator might force new user to have notification enabled only. I wanted exactly the opposite: I wanted my new users to enable this feature later, on their own will after registration, with notification disabled by default.

Here is a new patch with best of 2 worlds:
- hide/display Notification setting on registration form
- default value for new user : notification enabled or disabled

Mike

matt2000’s picture

I like #10. Has anybody tested it?

ishmael-sanchez’s picture

Status: Needs review » Needs work

Before the patch on a vanilla install:
check box appears registration form
'Enabled' by default

After patch:
check box still appeared on registration form
'Enabled' still set by default

matt2000’s picture

So the new option to disable it on the admin settings form doesn't work?

ishmael-sanchez’s picture

Status: Needs work » Reviewed & tested by the community

Ok so upon further investigation:

- hide/display Notification setting on registration form
Works, but is enabled by default

- default value for new user : notification enabled or disabled
Works, but is enabled by default

matt2000’s picture

Status: Reviewed & tested by the community » Needs work

This doesn't apply cleanly against HEAD or the DRUPAL-6--1 branch. Please reroll, and I will commit. I'd like to do a new release with several fixes in the next couple weeks.

Michel Poulain’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Needs work » Patch (to be ported)
StatusFileSize
new2.04 KB

Hi Matt, here is the correction of the patch against your latest dev version.

gpk’s picture

Status: Patch (to be ported) » Needs review

Needs review I think..

matt2000’s picture

Status: Needs review » Fixed

On further thought, I'm taking back my comment in #9, and using a solution like the one proposed in #8.

The goal in #10 is therefore possible by granting 'access notify' permission to authenticated users, but not anonymous users.

I won't be supporting an option to sign-up users for notifications without giving them notice or opportunity to opt-out.

Michel Poulain’s picture

Matt2000, with the latest patch, users HAVE opportunity to opt-out : via their "Notification settings" panel and via the footer on each email.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

izmeez’s picture

I have posted a patch in http://drupal.org/node/870812 that includes options to show email notification checkbox on registration without user permission needed and to set default status as desired along with a few other UI changes.