Developer forum

Forum » Development » Web url property and user custom fields

Web url property and user custom fields

Ivan Marijanović
Ivan Marijanović
Reply

Hi people

We have setup with one website and several languages and each language has its own url added.So for example we have following situation:
Primary www.example.com
First Langauge: www.example.com/us-hr/
Second Langauge: www.example.com/jp-hr/

I am implementing redirect on login notification observer and what I need to do is follwing:

- each user has custom field named PageDomain which should contain the data about languge sie he used to register - for example User one should have stored "us-hr" in this field. When user logs in on any of pages it should be redirected to his primary language page so I need to get Url of page he logs in on and if it is different then users PageDomain field value to redirect him. 

How can I get in my  NotificationObserver Url property of Website/Page I use to define domain (Apps - Websites - Website - Use in url)?

Also how can I get User custom fields. I can get them from templates using theri system name which have AccessUser_ in fron of the user name but how can I get them from NotificationObserver?

Thanks in advance!

Ivan

 


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Ivan,

We have some built in functionality for redirecting a user when logging in. See docs about start page.

Anyway, it seems like you need something different. I'm not sure I understand exactly what you need, but I'll try to answer your questions...

 

You can get the current page/website like this:

var pageView = Dynamicweb.Frontend.PageView.Current();

var currentWebsite = pageView.Area;

var currentPage = pageView.Page;

 

You can get the "Use in URL" values like this:

var currentWebsiteUrlName = currentWebsite.UrlName;

var currentPageUrlName = currentPage.UrlName;

 

You can get other websites like this:

var websites = Dynamicweb.Services.Areas.GetAreas();

 

You can get the users custom field values like this:

var customFieldValues = pageView.User.CustomFieldValues;

 

I hope this helps.

Best regards,
Morten

Votes for this answer: 1

 

You must be logged in to post in the forum