Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Need help with enabling Anonymous Profiles in Umbrco. We are using the member section in Umbraco for submitted form data via a Usercontrol.
In a normal ASP.NET project I can add ProfileMigrateEventArgs (via Global.asax) event to migrate the anonymous user data to a authenticated user.
Is this possible even in Umbraco? I have used Aaron blog post about Members Profile to add custom propertie: http://www.aaron-powell.com/umbraco-members-profiles
Code:
using System; using System.Web; using System.Web.Profile; using System.Web.Security; namespace PortalPlus.Umbraco.Core { public class PersonalizationModule : IHttpModule { public PersonalizationModule() { } public MemberProfile Profile { get { return (MemberProfile)HttpContext.Current.Profile; } } private bool IsNewProfile() { return (Profile.LastActivityDate == DateTime.MinValue && Profile.LastUpdatedDate == DateTime.MinValue); } void ProfileModule_MigrateAnonymous(object sender, ProfileMigrateEventArgs e) { if (IsNewProfile()) { MemberProfile anonProfile = Profile.GetUserProfile(e.AnonymousID); Profile.Namn = anonProfile.Namn; Profile.ForetagKommun = anonProfile.ForetagKommun; Profile.ForvaltningKontor = anonProfile.ForvaltningKontor; ProfileManager.DeleteProfile(e.AnonymousID); AnonymousIdentificationModule.ClearAnonymousIdentifier(); } } // In the Init function, register for HttpApplication // events by adding your handlers. public void Init(HttpApplication application) { for (var i = 0; i < application.Modules.Count; i++) { var profileModule = application.Modules[i] as ProfileModule; if (profileModule != null) { Log.LogResult(profileModule.GetType().FullName); profileModule.MigrateAnonymous += ProfileModule_MigrateAnonymous; } } } public void Dispose() { } } }
Handling the custom properties:
public class MemberProfile : ProfileBase { public MemberProfile GetUserProfile(string username) { return Create(username) as MemberProfile; } public static MemberProfile GetUserProfile() { return Create(Membership.GetUser().UserName) as MemberProfile; } [SettingsAllowAnonymous(true)] public string AuthGuid { get { var o = GetPropertyValue("auth_guid"); if (o == DBNull.Value) { return string.Empty; } return (string)o; } set { SetPropertyValue("auth_guid", value); Save(); } } [SettingsAllowAnonymous(true)] public string Namn { get { var o = GetPropertyValue("namn"); if (o == DBNull.Value) { return string.Empty; } return (string)o; } set { SetPropertyValue("namn", value); Save(); } } }
Finally how I trying to save the data:
try { var profile = (MemberProfile) System.Web.Profile.ProfileBase.Create(Guid.NewGuid().ToString()); profile.Namn = tbNamn.Text; profile.ForetagKommun = tbForetagKommun.Text; profile.ForvaltningKontor = tbForvaltningKontor.Text; profile.Save(); } catch(Exception ex) { Log.LogResult(ex.ToString()); }
Hi,
did you found a workaround for this?
I have the same problem.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Anonymous Profile with Membership via Usercontrol in Umbraco 4
Need help with enabling Anonymous Profiles in Umbrco. We are using the member section in Umbraco for submitted form data via a Usercontrol.
In a normal ASP.NET project I can add ProfileMigrateEventArgs (via Global.asax) event to migrate the anonymous user data to a authenticated user.
Is this possible even in Umbraco?
I have used Aaron blog post about Members Profile to add custom propertie: http://www.aaron-powell.com/umbraco-members-profiles
Code:
Handling the custom properties:
Finally how I trying to save the data:
Hi,
did you found a workaround for this?
I have the same problem.
is working on a reply...