Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Get user IP View modes: 
User avatar
Member
Member
Andrew - 10/3/2011 8:37:10 AM
   
Get user IP
I have a BizForm for our users to email comments. Is there a way to get their IP?

User avatar
Kentico Support
Kentico Support
janh-kentico - 10/3/2011 9:06:30 AM
   
RE:Get user IP
Hello Andrew,

You have to create your own custom macro as you can see below:
case "ipadd":
match = true;
result = HttpContext.Current.Request.UserHostAddress;
break;

Now you only add a new field into your BizForm and set the following properties:
Show on public form: false
Default value: {#ipadd#}

Jan Hermann

User avatar
Member
Member
Andrew - 4/27/2012 9:53:20 AM
   
RE:Get user IP
I understand the part about adding the new field to my BizForm, but I'm not seeing where I place the following code:

case "ipadd":
match = true;
result = HttpContext.Current.Request.UserHostAddress;
break;

Where do I put this?

I have been looking here to try and figure it out: Modules -> BizForms -> Using macros with BizForms

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/27/2012 5:27:10 PM
   
RE:Get user IP
Hi,

You need to create the code in the custom macro - please check out the link in the Jan's post "custom macro" and there you will find out the information, where to put the code :-)

Best regards,
Juraj Ondrus

User avatar
Member
Member
Andrew - 4/30/2012 6:38:22 AM
   
RE:Get user IP
I see what to do now. I missed it the first time. Thank you.

One last question, when I added my code to /CMSCustom.cs is that the reason I now see a new task called "Update Module 'BizForms'?
I'm guessing when I run this task it will update the /CMSCustom.cs file in my production environment?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/30/2012 2:40:39 PM
   
RE:Get user IP
Hi,

The CMSCustom.cs file is not synchronized via content staging, you need to copy it over manually.

And the task was logged probably because you added the macro to the BizForm field definition, didn't you?

Best regards,
Juraj Ondrus

User avatar
Member
Member
Andrew - 5/1/2012 6:56:34 AM
   
RE:Get user IP
I added code to CMSCustom.cs and then I add a field definition called "IP" to my BizForm that is names "FC3 Comment Form".

When I look at the task list I see two tasks. One titled Update BizForm 'FC# Comment Form' and the second task titled Update Module BizForm

I know the Update BizForm 'FC# Comment Form' task came from me adding the 'IP' field with Default value = {#ipadd#}

but I don't know what the Update Module BizForm
task came from.



User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 5/1/2012 7:44:38 AM
   
RE:Get user IP
Hello,

The second task will be associated with the general change of a bizform. You can check the database for more information on what content is synched. For this please check the table Staging_Task.

Best regards,
Boris Pocatko