Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Require admin approval for all discussions ( not for comments, only discussions)

I read this. : http://vanillaforums.org/discussion/24015/require-mod-approval-for-all-discussions

But when I do it, comments also go for admin approve. I need to set admin approve for only discussions. Comments should be published automatically.

Is it possible?

Thanks

Comments

  • Options
    hgtonighthgtonight ∞ · New Moderator
    edited July 2015

    Hmmm... This is an interesting proposal. You can bypass the approval requirement by verifying the user, but that removes the restriction across all models.

    Lets hook into the comment model before saving, modify the user session so we bypass the check. Then hook into the comment model after the save and restore the previous user session change:

    private $oldVerificationState = null;
    
    public function commentModel_beforeSaveComment_handler($sender) {
        $user =& GDN::Session()->User;
        $this->oldVerificationState = $user->Verified;
        $user->Verified = true;
    }
    
    public function commentModel_afterSaveComment_handler($sender) {
        if(!is_null($this->oldVerificationState)) {
            $user->Verified = $this->oldVerificationState;
            $user =& GDN::Session()->User;
        }
    }
    

    This should work with minimal invasion. Not the greatest, since you are manipulating a session rather than lifting the restriction, but I can't think of another way without modifying the model.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.