Hi,

I've installed the module, but it does not seem to show any effect. It does not matter which role I allow to subscribe to a newsletter, every role can subscribe every newsletter.

Is there anything else I have to do?

Which further information do you need?

Best regards,
iwasnet

Comments

klim_’s picture

Hi,
any effect after installation on my website, too.

Up

aacraig’s picture

Are you seeing this in 6.x or 7.x? I can replicate this problem in 7.x, and it has been fixed in the latest release.

gsquirrel’s picture

Also can't get this to work - all roles still see all newsletters. Am using version 6.x-1.2

aim2xl’s picture

Version: 6.x-1.x-dev » 6.x-1.2

I also had this issue on Drupal 6.22, Simplenews 6.x-1.3 with Simplenews Private Roles 6.x-1.2.

After installing and enabling Private Roles I cannot find any changes to any of the Simplenews pages. Finally spotted that I have "Content Access" module running and the role I was using (Not super admin) had not been granted the "manage private simplenews roles" Permission. As soon as this was enabled everything seems to work.

HTH..................

gsquirrel’s picture

Thanks but I don't think it is quite the same issue. I have the permissions set for simplenews private roles and the settings are there so you can choose which roles you want to access each list, the problem is that it has no effect, i.e. as normal authenticated user you can still see all the newsletters when looking at your "my newsletters" page.

gsquirrel’s picture

Maybe I am misunderstanding the module but the form I wanted to change has different form id to the one that is being altered by this module. If I change the form alter function to the user profile form the module seems to work as I expected it to originally.

In simplenews_private_roles.module I changed line 26 from

function simplenews_private_roles_form_simplenews_subscription_manager_form_alter(&$form, &$form_state) {

to

function simplenews_private_roles_form_user_profile_form_alter(&$form, &$form_state) {

aim2xl’s picture

gsquirrel,
You are right on both counts, I didn't check carefully enough the first time. All users were still able to select any newsletter in their "my newsletters" page.

After applying your code change I get the expected behavior, i.e. the "my newsletters" page only offers users the newsletters I want them to have based on their roles.

aacraig’s picture

This has been fixed in 7.x-1.3. I'll apply your change to 6.x and get a new release out soon.

bserem’s picture

any update on the fix?

thanks in advance

xaris.tsimpouris’s picture

Changed the line 42 in file .module file, from

function simplenews_private_roles_form_simplenews_subscription_manager_validate($form, $form_state) {

to

function simplenews_private_roles_form_user_profile_form_validate($form, $form_state) {

and problem solved for me!

EDIT: Sorry for the duplicate, made the same thing as http://drupal.org/node/1203078#comment-4798494 but I saw it afterwards.

iwasnet’s picture

http://drupal.org/node/1203078#comment-4798494 worked for me too, thank you.

i had an ugly error in the user/x/edit tab so i changed the code in the simplenews_private_roles.module like this:

function simplenews_private_roles_form_user_profile_form_alter(&$form, &$form_state) {
  $options = array();
  if ((strpos(drupal_get_path_alias($_GET['q']),"edit/newsletter")) <> FALSE) {
    foreach ($form['subscriptions']['newsletters']['#options'] as $tid => $name) {
      if (_simplenews_private_roles_has_access($tid)) {
        $options[$tid] = $name;
      }
    }
  }
  
  $form['subscriptions']['newsletters']['#options'] = $options;
  $form['#validate'][] = "simplenews_private_roles_form_simplenews_subscription_manager_validate";
}

and

function simplenews_private_roles_form_simplenews_subscription_manager_validate($form, $form_state) {
  if ((strpos(drupal_get_path_alias($_GET['q']),"edit/newsletter")) <> FALSE) {
    foreach ($form_state['values']['newsletters'] as $tid => $checked) {
      if (!_simplenews_private_roles_has_access($tid)) {
        form_set_error('newsletters', t("You aren't allowed to subscribe to this newsletter."));
      }
    }
  }
}

maybe this is useful for someone.

best regards,
iwasnet

inascon’s picture

By changing the name of the function simplenews_subscription_manager_form, like in #6, #10, or #11, you solve one and create another problem, because the form on /newsletter/subscriptions (simplenews_subscription_manager_form) will then not work properly.
To solve this issues I've added the following function to the .module:

function simplenews_private_roles_form_user_profile_form_alter(&$form, &$form_state) {
  if (isset($form['subscriptions']['newsletters'])) {
    return simplenews_private_roles_form_simplenews_subscription_manager_form_alter($form, $form_state);
  }
}

HTH

aacraig’s picture

Status: Active » Needs review

I've just released 6.x-1.3, which fixes this.

lavamind’s picture

I installed 6.x-1.3 (Drupal 6.24), but on the newsletter/subscriptions page, all newsletters are still available as an anonymous user, even though some of them require "authenticated user" role.

aacraig’s picture

@lavamind, could you post the exact URL of the page you see the newsletters on? There are a few forms that show the newsletter choices, and it's likely I've missed one.

lavamind’s picture

aacraig’s picture

Status: Needs review » Postponed

Due to a major project I will be managing, I won't be able to support the 6.x branch of this module.

I am happy to take on a co-maintainer if someone wants to maintain the 6.x branch, but otherwise my only suggestion is to upgrade to Drupal 7, which I will continue to support.