remove user account after a number of days
smilem
Joined: 2009-02-25
Posts: 118 |
Posted: Sat, 2010-02-13 17:59 |
How can I delete or deactivate user accounts after a number of days if the user does not log in? |
|
Posts: 4342
I posted a module on here that does something similar - disable a user some days after they register. You could modify it. A search on this forum should turn it up.
Posts: 118
Well I searched for "delete or deactivate user accounts" and "deactivate user accounts" can't seem to find anything?
Posts: 4342
http://www.google.co.uk/search?q=site:gallery.menalto.com+user+time+limit+alecmyers
first hit
Posts: 118
Thanks, I should have used google for searching not forum search.
After isntalling I had to restore site from backup because I could not login even as admin.
As I understand these lines check and deny user login after 30 days if user is not admin:
if (!$isAdmin && $age > 86400 * 30)
$error[] = 'form[error][invalidPassword]';
$success = false;
}
Can you give me some hints on how to check for user inactivity instead of a flat line like 30days?
When deleting a user in gallery2 you can choose to
1. assign photos to another user
2. delete them.
I would like to make second choice have them just deleted,I have no idea how a delete user
Posts: 4342
Shouldn't be the case. Regardless in future see FAQ: How can I deactivate a module when I am unable to login?
Not sure if G2 actually records logins at all. Otherwise you'll have to write an event handler for the login event, build a db table to record logins, record them etc etc. Pretty straightforward if you're an experienced G2 programmer, massive task if you're not.
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methoddeleteEntityById
Follow the core code to see how it handles owned items on user deletion.
Posts: 118
When I click "Site Admin" -> "User Info"
I can see data like "This will display information about users when they Login, Logout, and Failed Login Attempts. "
ID, User ID, User Name, IP Address, Time Stamp (Sat 20 Feb 2010 01:58:44 AM EET ) and Action (Login) or (Failed Login) or (Logout).
So I think gallery2 has all the data that is required to check when user last logged out, or when last login was made.
Yes I'm not "experienced G2 programmer" but all I'm looking for is if it's possible for help on modifying perhaps this module for this task.
I'm not sure why I could not login after installing it, see attached image in my above post. The login buttons were gone, and pushing enter key did nothing.
Posts: 4342
That'll be the userinfo module (http://codex.gallery2.org/Gallery2:Modules:userinfo), non-core, contributed by the community. I don't know much about it. Obviously you need to think carefully about introducing inter-module dependencies. Actually you may be better off hacking your code changes into that module, to reject an out-of-time login.
Also note that won't delete the user, and if you program it to, they won't get deleted until the next time they try to login. Gallery doesn't have an effective mechanism for doing actions at a prearranged time, everything is triggered by web page views, so you have to piggy-back off some other event.
Curious. That module isn't programmed to have that effect.
Posts: 118
Well my work flow is like this:
1. User registers
2. Gallery creates usernamefolder by using useralbums
3. User uploads photos for printing
4. I download the photos via ftp and delete them via admin
5. if user does not login back to the site within say 60days I'm looking for way to list this type of users and delete them.
I was thinking to try to list users in phpmyadmin but g_timeStamp fields has just numbers like "1256324867" what do they mean, how can get normal date view?
query
returned zero rows as I can't figure out how to request correct timestamp
Posts: 4342
The timestamp is a unix timestamp. You can google for that. You need to subtract the current system time and divide by 86400 to get the number of days. Check the code in the module I wrote and linked to above.
Posts: 118
I finally managed to build my sql for selecting users in phpmyadmin after certain date that are not an admin and last action was login:
I'm still puzzled how to make it into workable code for your script:
Posts: 4342
That script isn't an appropriate place for what you're trying to do. The script I wrote is triggered on the login of an individual user, and allows/denies that user only. If you want to trawl the entire user list then you need to find another approach to the one I took.
Posts: 118
I have a table where user logins are registered
Table is called g2_UserinfoMap and it looks like this:
g_id | g_userId | g_userName | g_ipAddress | g_timeStamp | g_action
Records in table are added after each user login to the site:
I'm trying to make a a select query to show users that were not logged in the last 3 months to the site so I could delete them from site management interface manually by hand.
Unfortunately I'm not so good with SQL and my query above just lists users after certain date.
The unixtime field "g_timeStamp" is varchar for some reason.
I tried to filter users like this but get not what I need:
So perhaps anyone know how to build such quary, Any ideas?
I read perhaps it's required to use left join but how to use it?