Hi,
So I'm building a website that allows all authenticated users to post comments without approval. However for various reasons I need to allow comments to be unpublished. Unfortunately there's a line of code in Comment Access's implementation of hook_comment_presave() that is forcing the comments to be published.

function commentaccess_comment_presave($comment) {
  // Check if the comment needs approval.
  ...  
  else {
    // No approval necessary: post comment directly!
    $comment->status = COMMENT_PUBLISHED;
  }
}

My solution for now was simply to comment out the line of code for now as that met my requirements.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Bagler’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Assigned: Unassigned » Dave Bagler
Status: Active » Needs review
FileSize
593 bytes

I've attached a very small patch (just comments out the one line and explains why).

Dave Bagler’s picture

Assigned: Dave Bagler » Unassigned
Alan D.’s picture

Falling back to core permissions is better maybe?

$status = (user_access('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED);

So better to do nothing here? It should already be set

Dave Bagler’s picture

I ended up coding a smaller custom solution that just met my specific requirements rather than the more broad requirements of the comment access module. @Alan D. You're probably right, core permissions might be a better solution to this issue.

loze’s picture

Issue summary: View changes

I ran into this bug with a custom module that should of been publishing/unpublishing comments. Took me forever to figure out what was interfering.

I think this commentaccess should simple check if the comment object has a cid and bail if it does. We only need it acting on new comments not when editing existing comments.

I propose putting the following at the beginning of commentaccess_comment_presave():

if(!empty($comment->cid)){
return;
}