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 do I figure out which user is banned?

BboyHavocBboyHavoc New
edited July 2012 in Vanilla 2.0 - 2.8

So I'm trying to figure out how I can create an icon or text to put next to a banned user's name within a discussion. I'm having a hard time trying to get the role value of a banned user or even trying to figure out if that user has been banned already.

I've set up a test user which has posted several comments on a discussion and have then banned that user. What I want is to figure out how to put some kind of icon or text next to his name to signify that that user has been banned.

I tried using (within discussion/helper_functions.php):

$banned = BanModel::CheckUser($Object->InsertUserID);

but I keep getting a value of 1 each time for all users (banned or not). Any clues on how to find out how I can go about that?

Tagged:

Comments

  • peregrineperegrine MVP
    edited July 2012

    Don't know why checkuser won't work the way you think it would, unless all have the same last ip address, or email, or name as the test user.

    A solution but ....
    A really inefficient way to check if person is banned in helper functions.php

      $bID = $Object->InsertUserID;
               $Banned = Gdn::Database()->SQL()->Select('Banned')->From('User')->Where('UserID',$bID )->Get()->FirstRow();
    
               if ($Banned->Banned == "1") echo "Banned"
    

    on another note:
    It doesn't make sense to me why you don't look in the banned list and put a date you banned and delete when you want.

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

  • 422422 Developer MVP

    Create usergrp called banned, assign the ug an id. Echo that id and fire css element. Simple.

    There was an error rendering this rich post.

  • that would be quicker if you could pick the usergroup of the ban is not by ip address.

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

  • I can't edit above just meant that would be quicker - what you said 422.

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

  • peregrineperegrine MVP
    edited July 2012

    don't understand this function @Todd

    if called from helper_functions.php

     $Banned = BanModel::CheckUser($Author->UserId);
    or 
     $Banned = BanModel::CheckUser($Author->Name);
    
    
    in class.banmodel.php
    
    if (preg_match($Regex, GetValue($Fields[$Ban['BanType']], $User))) {
    
    $Regex - is the Author  name
    
    GetValue($Fields[$Ban['BanType']], $User))) -  always returns null
    
    and 
     count($Banned) is always zero.
    
    so it always returns true.
    

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

  • I did just create a banned user group and put banned users in there and use that usergroup id as reference, but I would still prefer a better solution to grab banned users without having to put them in another usergroup.

    Also, like what @peregrine said, it still won't grab users from banned ip addresses.

  • if you want to grab users from banned ip addresses just do a lookup of the the authors last ip address and cmpare to the banned user table ip address. It is going to be so intensive on every discussion, it is hardly worth the bother. What is your goal to display some thing in the discussion views or to just find out the names that match the ip addresses. Which you could do outside the program with phpmyadmin and no detriment to the use of your forum. Perhaps when you ban an qp in the future you should put the username associated with it in the notes on the dashboard associiated with banned users.

    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.