Skip to Content Skip to Menu

Discouraging Login Sharing

  • Richard67
  • Richard67
  • OFFLINE
  • Posts: 30
  • Thanks: 1
  • Karma: 0
12 years 3 months ago - 12 years 3 months ago #205147 by Richard67
Replied by Richard67 on topic Re: Discouraging Login Sharing

Richard67 wrote: Hi Krileon,

krileon wrote: For example using CB Auto Actions to store ip address to a field upon login


How can I get the user's current IP address within auto actions?

Ha, I've made it.

Only question now is if there would have been an easier way.

Following I've made:

I created a new text field "cb_remoteipaddress" -next time I will use shorter names ;-) - and assigned it to a tab which is not shown in user profile. The field is also not shown in registration, so the only "green light" in the field manager list is the one in the "published" column.

In auto actions I've created an action as follows:

type = code
trigger = onAfterLogin (or whatever is needed)
method = PHP (eval)
code:
Code:
global $_SERVER, $_CB_database; $remoteip = $_SERVER["REMOTE_ADDR"]; $_CB_database->setQuery("UPDATE #__comprofiler SET cb_remoteipaddress='" . $remoteip . "' WHERE user_id=[cb:userdata field="user_id" user="#me" /]"); $_CB_database->query();
return = silent

I use the IP address for an email I get if someone has successfully logged in on my site, so I've set up a second auto action of type "Email" with trigger "onAfterLogin" and a later order number, which sends me an email with following content:

User "[name]" has logged in from [cb_remoteipaddress] at [cb:date format="Y-m-d H:i:s" /].

Is maybe a nice use case for the documents?

Please let me know if there would have been an easier way to do this.

Thanks

Richard67
Last edit: 12 years 3 months ago by Richard67.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum