以编程方式从 Umbraco 中的成员获取属性
我认为这真的很简单,但是..
我们创建了一个用户和一个具有各种属性的成员类型 当我们尝试通过成员对象访问属性时,我们什么也没得到。
//成员 m 是当前用户,
例如。 属性 s = m.getProperty("首选用户名"); is null
m.getProperties 的计数为零..
我们是否错过了一些明显的东西?
I thought this would be really simple but ..
We've create a user and a member type with various properties
When we try to access the properties via the member object we got nothing.
//Member m is current User
eg.
Property s = m.getProperty("PreferdUserName");
is null
m.getProperties has a count of Zero..
have we missed something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
会不会有拼写错误?
“PreferdUserName”可能希望是“PreferredUserName”。
除此之外它看起来是正确的。
Could there be a spelling error?
"PreferdUserName" may want to be "PreferredUserName".
Other than that it looks correct.
最后,我求助于将成员属性存储在单独的数据库表中,无论如何,这更接近我的需要。
我认为这与我使用自定义 msbuild 任务从外部 umbraco 创建 memberType 的方式有关。
In the end i resorted to storing member properties in a separate db table, which anyhow is closer to what i need.
I presume it had something to do with the way I created the memberType from outside umbraco using a custom msbuild task.
您可以创建自己的类并扩展 ProfileBase。下面的代码将公开您在 Umbraco 中创建的属性。例如 umbraco 别名是“first_name”。
然后您可以访问像这样的属性...
有关如何设置这一切的更多信息可以在此处查看:
http://www.aaron-powell.com/posts/2010-04-07-umbraco-members-profiles.html
You could create your own class and extend ProfileBase. The code below will expose the properties that you have created within Umbraco. e.g. umbraco alias is 'first_name'.
Then you can access properties like so...
More info about how to set this all up can be seen here:
http://www.aaron-powell.com/posts/2010-04-07-umbraco-members-profiles.html
如果您需要获取 Umbraco 中当前用户以外的其他人的成员详细信息并拥有他们的用户名,这可能会对其他人有所帮助。
This might help someone else, if you need to get member details for someone other than the current user in Umbraco and have their Username.
尝试
如果仍然不起作用,请查看这篇关于成员属性的精彩文章
http://legacy.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx
Try
If that still doesn't work, then check out this great post about member properties
http://legacy.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx