Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Ability to capture IP address of user?

 

 


nmsinc
User

Sep 26, 2011, 1:07 PM

Post #1 of 4 (720 views)
Shortcut
Ability to capture IP address of user? Can't Post

Does CMS Membership plugin have the ability to capture and record users IP address?

Thanks


Dave
Staff / Moderator


Sep 26, 2011, 10:47 PM

Post #2 of 4 (716 views)
Shortcut
Re: [nmsinc] Ability to capture IP address of user? [In reply to] Can't Post

Hi nmsinc,

No, it doesn't, but you could do that pretty easily with a little custom code.

The users IP address is always stored in $_SERVER['REMOTE_ADDR']

So if you have a recent CMSB version you could create a field in the accounts table called 'last_ip' use the mysql_update() function like this:


Code
// Save users last IP 
$usersIpHasChanged = ($CURRENT_USER && $CURRENT_USER['last_ip'] != $_SERVER['REMOTE_ADDR']);
if ($usersIpHasChanged) {
mysql_update('accounts', $CURRENT_USER['num'], null, array('last_ip' => $_SERVER['REMOTE_ADDR']));
}


That code is untested, but that should point you in the right direction. Let me know if that works for you or if you have any other questions.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com
 


Toledoh
Enthusiast

Sep 26, 2011, 11:55 PM

Post #3 of 4 (714 views)
Shortcut
Re: [Dave] Ability to capture IP address of user? [In reply to] Can't Post

Hey Dave,

This would be a good thing to tie into core functionality... especially for user sign-ups to the membership database etc, but also purely on records being edited...

Just another one for the list ;)
Cheers,

Tim Forrest
Toledoh Enterprises
www.toledoh.com.au


nmsinc
User

Sep 27, 2011, 7:15 AM

Post #4 of 4 (699 views)
Shortcut
Re: [Toledoh] Ability to capture IP address of user? [In reply to] Can't Post

That's what I was looking for - thanks for the help!