• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Ban via database with reason - is this possible?

#1
Hi all,

I've searched but was unable to find what I am looking for, hence asking for your help if possible.

I have some users (90+) that don't log in to the forum for quite some time, and I would like to ban them, although giving a reason to the ban.


To find the users that have not logged in this year and that are not banned, I used the following statement:
select * from xf_user
where last_activity < unix_timestamp ('2013-01-01 00:00:00')
and is_banned = 0


To simply ban them on the database, I can use the following sql statement:
update xf_user set is_banned = 1
where last_activity < unix_timestamp ('2013-08-01 00:00:00') and is_banned = 0


And I assume that the ban reason goes on xf_user_ban table, but this table is indexed by user_id. Is there any way to apply the xf_user.is_banned = 1 and add the user id and ban reason to xf_user_ban in the same sql statement?
Something like the below (which obviously doesn't work)

update xf_user set is_banned = 1 and xf_user_ban set user_reason = 'Yearly Login missing'
where last_activity < unix_timestamp ('2013-08-01 00:00:00') and is_banned = 0


Thanks in advance.
Antonio
 
#3
Hi Brogan,
Thank you for your quick reply.
I have tried that option, but it doesn't allow me to specify a 'special reason' for the ban :( although in lack of a better one, is a viable option.
 

Brogan

XenForo moderator
Staff member
#4
I wouldn't recommend banning by directly editing the database as I'm not sure which tables are updated.

However, manually changing the text in xf_user_ban.user_reason should be OK.
You can do that afterwards.