Get properties from a member in Umbraco programmatically

I thought it would be very simple, but ..

We create a user and a member type with various properties. When we try to access properties through a member object, we got nothing.

// Member m is the current user

eg. Property s = m.getProperty ("PreferdUserName"); is null

m.getProperties has a zero counter.

did we miss something obvious?

+3
source share
5 answers

Try

Property s = m.getProperty("PreferdUserName").value;

If this still doesn't work, check out this great article on member properties.

http://legacy.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx

-1
source

Could there be a spelling mistake?

"PreferdUserName" "PreferredUserName".

, .

0

db, , . , - , memberType - umbraco, msbuild.

0

ProfileBase. , Umbraco. umbraco "first_name".

[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);
    }
}

...

string firstName = ((MemberProfile)HttpContext.Current.Profile).FirstName;

, , :

http://www.aaron-powell.com/posts/2010-04-07-umbraco-members-profiles.html

0

This may help someone else if you need to get member information for someone other than the current user in Umbraco and have your username.

var TheirUsername = "s12345";

Member MemberFind = new Member(Convert.ToInt32(Membership.GetUser(***TheirUsername***).ProviderUserKey));

//now use this value

var NameOfUser = MemberFind.Text;

var EmailAddress = MemberFind.Email;
0
source

Source: https://habr.com/ru/post/1743407/


All Articles