My comment boxes do not show the checkbox defined in

function anon_comment_form_comment_form_alter(&$form, &$form_state) {
  global $user;
  //no need to alter the form if we're already anonymous
  if ($user->uid == 0) {
    return;
  }
  //implement the checkbox on the comment form
  $form['anonymize'] = array(
    '#type' => 'checkbox',
    '#title' => t('Post this comment anonymously'),
    '#default_value' => 0,
    '#weight' => '10',
    '#access' => user_access('comment anonymously when logged in')
  );

I assume the weight of the created item is too low

the print_r($form)

....
[#submit] => Array
        (
            [0] => anon_comment_form_submit
            [1] => comment_form_submit
            [2] => anon_comment_log_author
        )

    [anonymize] => Array
        (
            [#type] => checkbox
            [#title] => Post this comment anonymously
            [#default_value] => 0
            [#weight] => 10
            [#access] => 
        )

The anonymize is placed _last_ in the array as you may see in http://drupalbin.com/18726

CommentFileSizeAuthor
Screenshot of comment-anonymizer20.11 KBwroxbox

Comments

wroxbox’s picture

By removing the '#access' => user_access('comment anonymously when logged in') I got the checkbox printed to form.

Permissions are allowed to authenticated users.

markie’s picture

Status: Active » Closed (cannot reproduce)

I wasn't able to reproduce this on a couple of machines. I would guess that permissions weren't set properly. Please let me know if you are still having a problem with this.

wroxbox’s picture

Version: 7.x-1.0-rc2 » 7.x-1.0
Component: User interface » Code
Status: Closed (cannot reproduce) » Needs review

Ok - found the bug

the permission table is setting permission into "comment anonymously"

function anon_comment_permission() {
  return array(
    'comment anonymously' => array(
      'title' => t('Comment anonymously, even when logged in.'),
    ),
  );
}

so you need to check permissions against that value anon.comment.module line 39

function anon_comment_form_comment_form_alter(&$form, &$form_state) {
  '#access' => user_access('comment anonymously')  //OLD '#access' => user_access('comment anonymously when logged in')
}
markie’s picture

Status: Needs review » Fixed

Good catch. I have added the change to the dev branch. I'll make a few tests and see if we want to add any changes before adding a new release.

Status: Fixed » Closed (fixed)

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

wonder95’s picture

Status: Closed (fixed) » Active

Is this going to be fixed? I don't see any commits in the repo other than the initial commit. I can roll a patch if needed.

wonder95’s picture

Status: Active » Closed (fixed)

Oops, my bad, I see it fixed and committed.

DevJoshLopez’s picture

I just downloaded and am using the 7.x-1.0 version and I cant see the checkmark under the comment form. What version is this fixed in?

xbl’s picture

2wroxbox: Thx a lot! now it works
215handsmedia: to see checkbox under the comment form you should make changes (comment #3) in line 39 anon_comment.module before the installation of this module (ver. 1.0)

function anon_comment_form_comment_form_alter(&$form, &$form_state) {
  '#access' => user_access('comment anonymously')  //OLD '#access' => user_access('comment anonymously when logged in')
}