Hi people...
I made one code, basicly to get all user custom fields and publish on Global Tags...
Work fine when the customers have just one group. When they have more than one i got some problens.
After my code, I got timeout... I mean, they don't do anything and still running all the time.
Someone can help?
The code:
using Dynamicweb.Modules.Common.CustomFields;
namespace www.humanpixels.com.CustomModules.HupxPriceProvider
{
[Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.Standard.Page.OnGlobalTags)]
//public class PageviewObserver : Dynamicweb.Extensibility.NotificationSubscriber
public class HupxProductListTemplateExtender : Dynamicweb.Extensibility.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
{
if (args == null)
return;
Dynamicweb.Notifications.Standard.Page.PageviewNotificationArgs pna = (Dynamicweb.Notifications.Standard.Page.PageviewNotificationArgs)args;
Dynamicweb.Modules.UserManagement.User user = Dynamicweb.Modules.UserManagement.User.GetCurrentUser();
if (user != null)
{
foreach (CustomFieldValue val in user.CustomFieldValues)
{
Dynamicweb.Modules.Common.CustomFields.CustomField field = val.CustomField;
object fieldValue = val.Value;
if (val != null)
{
pna.Template.SetTag("Hupx_" + field.Name, val.Value.ToString());
}
}
}
}
}
}