Ability to capture IP address of user?

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

Thanks
nmsinc

Re: [nmsinc] Ability to capture IP address of user?

By Dave - September 27, 2011

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:

// 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

Re: [Toledoh] Ability to capture IP address of user?

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