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.

How can I add 'ban' button to user profile?

I would like to let moderators ban users. Though I would not like to give them permission to edit user.

Is it possible? What should I hack for this? If there is plenty of work to do I will pay for development of such plug in for vanilla.



  • Options

    I'm looking to use this solution as well... Currently the only way to give access to moderators of the BAN function is to grant them almost full control of the dashboard, that I did not want.

    There is an option of delete user but I want a ban option for the moderator as well.

  • Options
    hbfhbf wiki guy? MVP

    im not aware of a plugin that provides this functionality. it could be written though.

  • Options
    businessdadbusinessdad Stealth contributor MVP

    @hbf said:
    im not aware of a plugin that provides this functionality. it could be written though.

    Yes, I confirm that there isn't something like that around, yet.

  • Options

    I hate to add to slightly old discussion, but has anyone come up with anything for this?
    Ban button on profile would be very useful. :)

  • Options
    hgtonighthgtonight ∞ · New Moderator

    User banning is actually done through the Ban Model. Models don't check permissions (controllers do, iirc). So you would have to hook in to the user profile page and add a button. Then you would have to actually call a custom ban function

    public function ProfileController_BeforeStatusForm_Handler($Sender) {
      // Create your button here
      // With this sample code, your link should be '/profile/banbutton/userid'
      // Don't forget to check permissions!
      // Check a role
      // Should also check to see if the user is already banned and issue an unban button
      // '/profile/banbutton/userid/unban'
    public function ProfileController_BanButton_Create($Sender) {
      // find the userid in the requests
      $Request = $Sender->Request->GetRequestArguments();
      // You will have to dump the $Request var to find which variables match up to what
      $UserID = $Request[1];
      $BanMode = ($Request[2] == 'unban') ? FALSE : TRUE;
      // Get the user object from the userid
      $UserModel = new UserModel();
      $User = $UserModel->GetIDs($UserID);
      $BanModel = new BanModel();
      $BanModel->SaveUser($User, $BanMode);

    You will have to come up with your own logic to check to see if the user should be able to see the button. You will also have to verify that I guessed the proper request variable indexes.

    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
    LincLinc Detroit Admin

    It's already in 2.1, fwiw.

Sign In or Register to comment.