Well-Trained Mind Press Posted May 2, 2017 Posted May 2, 2017 Hey all, I want to get the number of unique users who logged into the site over the last 30 days. Does anyone have any ideas on how to do this? John
CP Posted May 2, 2017 Posted May 2, 2017 I created a Member Stats page for admins only. What I did was go to the Block Manager/System and then selected Members and moved it over to my page. I then created a list for the last 25 members who visited. You can add more or less members if you want. Although it is not for a month like you are asking it gives you an idea who has visited within a month by just hovering over there name on the list. If you are interested in doing this I added a few screenshots for how to set it up: Very easy to do. If you play around with it you can actually set up a few blocks giving you useful information.
clearvision Posted May 2, 2017 Posted May 2, 2017 If you truly just want the NUMBER of unique users that visited (with ids so logged in). You can make a php block: $monthago = time() - 2592000; //30days $where = 'last_visit > '.$monthago; try { $select = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where ); }catch( \IPS\Db\Exception $e ){} $countasarray = iterator_to_array($select); print $countasarray[0];
SJ77 Posted May 2, 2017 Posted May 2, 2017 Would it be better if your query select was 'COUNT(core_members') @clearvision
Well-Trained Mind Press Posted May 2, 2017 Author Posted May 2, 2017 Ok, so we are running IP.Board 3.4.x and I run a sql query. This is just for my purpose and not to be broadcasted. John something like "Select count(*) from ipb_members where last_activity > (SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 day)))" ? correct.
clearvision Posted May 2, 2017 Posted May 2, 2017 1 hour ago, superj707 said: Would it be better if your query select was 'COUNT(core_members') @clearvision Well core_members is the table. Only reason to filter on a specific column is if you don't want rows with null in that column. This does not try to detect state of member. If you want specific member classes (rule out validating, banned, etc. ) the the where is more complicated. If you have alot of false registrations hanging around may need to add more to it. Edit: I can confirm that it will include validating members on 4.1 as they are part of your "entry" group. It does not affect what I was doing as I also checked for a profile pix. With 4.1 I'm not sure how you can tell if they are validating versus real members. They evidently have guest privileges either set or with a flag (I don't see a flag on quick look) and since I don't need it, not going to dig for it...
Well-Trained Mind Press Posted May 2, 2017 Author Posted May 2, 2017 I don't have core_members in my db. only ipb_members
clearvision Posted May 2, 2017 Posted May 2, 2017 My comment was for 4.x. That might be right for 3.x, don't remember. Also last_activity means they did something, versus they were just there (last_visit) if it matters (at least on 4.x)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.