1
biomech
Suspending User Accounts
  • 2011/1/19 7:09

  • biomech

  • Not too shy to talk

  • Posts: 161

  • Since: 2002/2/25


Hi all,

My site has a rule that users have to provide their real names when registering. I want to write a script that periodically checks the Real Name field (which I added to the user profiles) to see if it is empty or contains only one word. Then, for those accounts, I want to suspend or deactivate them so that they can no longer be used.

At the same time, I want to maintain the display of the user's username in the forum threads in order to maintain the integrity of the thread conversations, so I don't want to have something like "Anonymous" or "Unsubscribed" or "Deleted" displayed there - I want to keep the user name there.

Can anybody advise me on the best way of doing this?

Thanks,

- b -

2
redheadedrod
Re: Suspending User Accounts

Best way is to probably make a group and give it no permissions. This would make that user "worse" than anonymous but still allow them to be displayed. Then all you need to do is add them to that group and remove them from any other groups.

3
Mazarin
Re: Suspending User Accounts
  • 2011/1/19 19:19

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


The User Profile module gives you the possibility to deactivate the user so that he/she cannot log in (but are still left in the db, all groups etc).

4
Balzac
Re: Suspending User Accounts
  • 2011/1/20 0:24

  • Balzac

  • Just popping in

  • Posts: 68

  • Since: 2010/1/11


Searched for it, cannot find this module. Where is the latest version for download findable?

5
biomech
Re: Suspending User Accounts
  • 2011/1/20 1:05

  • biomech

  • Not too shy to talk

  • Posts: 161

  • Since: 2002/2/25


Thanks RHR,

Any advice for automating this with a script to search for users without names in this field and then move them to the other group? (I can code the DB search, but don't know how to go about coding the assignment to another user group...)

Thanks,

-b-

6
xoobaru
Re: Suspending User Accounts
  • 2011/1/20 1:12

  • xoobaru

  • Just can't stay away

  • Posts: 494

  • Since: 2010/12/2



7
redheadedrod
Re: Suspending User Accounts

Quote:

Balzac wrote:
Searched for it, cannot find this module. Where is the latest version for download findable?


profile module.. It is included with the core package...

8
redheadedrod
Re: Suspending User Accounts

You should be able to search with the profile module.. I think it is in the admin portion of the profile module. Look for a "search for user" or something similar. I don't know that without coding if you will have an easy way to do this. If you know SQL at all and know the fields and required values you could probably do it easier with SQL queries.

You could actually probably do this quite easily with a simple SQL query to search the user name fields for blank entries and set the group they are in to be the group you want.

I haven't messed around yet with it so I couldn't tell you the exact method...

You could also then add code to your theme to check for the group and if in this banned group they could be flagged somehow.

By using groups to do this you can also control other aspects of their access.. Like maybe give them access to profile to change their name or something.

When you have the right SQL statement you can likely even setup a cron to run once a day to do this automatically. But if you do that then you would likely want to also have another cron event to put them back to a normal user if they enter a name.

Hopefully someone else can help you with the correct SQL statement. I am unsure without trying it out myself and I am sure someone here can just list the code easily.


Rodney

9
biomech
Re: Suspending User Accounts
  • 2011/1/20 5:09

  • biomech

  • Not too shy to talk

  • Posts: 161

  • Since: 2002/2/25


Thanks Rodney, I'll give that a try. My SQL is good enough to do it - I just need to look at the table structure. (I didn't know if assigning a different group is more complicated than just changing one value in one field in one table, or if there are table relationships that need to be taken into consideration.)

Cheers,

-b-

10
redheadedrod
Re: Suspending User Accounts

You would use I believe an insert statement to change the field for users to the value you want where the real name is blank.

You would want to set the user groups field to just containing the group for the banned users.

You may be able to do this with one SQL statement but make sure you assume they are currently in other groups and set this value accordingly. You want to remove them from all groups and add them to just your special one.

Worst case you may need basically the same sql statement with the first one totally clearing the groups field then the second one inserting just the group you want them in. I have not looked at this code yet and I don't have time right now but it should be somewhat easy.


A couple quick notes...

The above is assuming that you are already connected to the database...

If you do this in a cron you will have to also connect to the database before you can do the above SQL statements. If you put a script on your system to do this make sure you do not put it into your "document root" a good place would be in your xoops_lib directory. You don't want the connect information for your database to be in a place anyone can view it if something screws up with the server.

Login

Who's Online

389 user(s) are online (269 user(s) are browsing Support Forums)


Members: 0


Guests: 389


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits