I have a custom membership provider that I'm using to capture custom information from users. I have a couple of true / false fields that I'm trying to check when the member is created but I'm having not luck. I have tried to create a custom property too pass in but I can't get it to work.
public class MemberProfile : ProfileBase,IDisposable {
public static MemberProfile GetUserProfile(string username) { return Create(username) as MemberProfile; }
public static MemberProfile GetUserProfile() { return Create(Membership.GetUser().UserName) as MemberProfile; }
[SettingsAllowAnonymous(false)] public string AuthGuid { get { var o = base.GetPropertyValue("auth_guid"); if (o == DBNull.Value) { return string.Empty; } return (string)o; } set { base.SetPropertyValue("auth_guid", value); } }
[SettingsAllowAnonymous(false)] public string FirstName { get { var o = base.GetPropertyValue("first_name"); if (o == DBNull.Value) { return string.Empty; } return (string)o; } set { base.SetPropertyValue("first_name", value); } }
[SettingsAllowAnonymous(false)] public string LastName { get { var o = base.GetPropertyValue("last_name"); if (o == DBNull.Value) { return string.Empty; } return (string)o; } set { base.SetPropertyValue("last_name", value); } }
[SettingsAllowAnonymous(false)] public string MiddleName { get { var o = base.GetPropertyValue("middle_name"); if (o == DBNull.Value) { return string.Empty; } return (string)o; } set { base.SetPropertyValue("middle_name", value); } }
[SettingsAllowAnonymous(false)] public Boolean isApproved { get { var o = base.GetPropertyValue("is_Approved");
return (Boolean)o; } set { base.SetPropertyValue("is_Approved", value); } }
True or false not being checked on member
Hi There,
I have a custom membership provider that I'm using to capture custom information from users. I have a couple of true / false fields that I'm trying to check when the member is created but I'm having not luck. I have tried to create a custom property too pass in but I can't get it to work.
I've tried boolean and string datatypes.
Thanks in advance
Sean
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
CreateUserWizard cuw = (CreateUserWizard)sender;
string strUserName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("Username")).Text;
MembershipUser user = Membership.GetUser(strUserName);
if (cuw != null)
{
string newUserGuid = System.Guid.NewGuid().ToString("N");
Members.MemberProfile mp = Members.MemberProfile.GetUserProfile(strUserName);
if (mp != null)
{
mp.AuthGuid = newUserGuid;
mp.FirstName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("FirstName")).Text;
mp.MiddleName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("MiddleName")).Text;
mp.LastName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("LastName")).Text;
mp.isApproved = true;
mp.Save();
Roles.AddUserToRole(strUserName, "Retail");
}
}
}
----------------------- member profile class
public class MemberProfile : ProfileBase,IDisposable
{
public static MemberProfile GetUserProfile(string username)
{
return Create(username) as MemberProfile;
}
public static MemberProfile GetUserProfile()
{
return Create(Membership.GetUser().UserName) as MemberProfile;
}
[SettingsAllowAnonymous(false)]
public string AuthGuid
{
get
{
var o = base.GetPropertyValue("auth_guid");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("auth_guid", value);
}
}
[SettingsAllowAnonymous(false)]
public string FirstName
{
get
{
var o = base.GetPropertyValue("first_name");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("first_name", value);
}
}
[SettingsAllowAnonymous(false)]
public string LastName
{
get
{
var o = base.GetPropertyValue("last_name");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("last_name", value);
}
}
[SettingsAllowAnonymous(false)]
public string MiddleName
{
get
{
var o = base.GetPropertyValue("middle_name");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("middle_name", value);
}
}
[SettingsAllowAnonymous(false)]
public Boolean isApproved
{
get
{
var o = base.GetPropertyValue("is_Approved");
return (Boolean)o;
}
set
{
base.SetPropertyValue("is_Approved", value);
}
}
bool is_disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!is_disposed)
{
}
this.is_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
//}
!---- web config settings
<add name="auth_guid" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
<add name="first_name" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
<add name="last_name" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
<add name="middle_name" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
<add name="is_Approved" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.Boolean" />
is working on a reply...