I just downloaded newest umbraco 6.0 and playing arround with it...
So what I am having trouble with:
Pull out a member from all members by UserName.
Than access it's properties (f.ex. Name)
Than I want to add some other properties (like age, currentLocation and stuff like that...)...
For now I have this...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using umbraco.cms.businesslogic.member;
namespace members_test
{
public partial class PublicIndex : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string mbr_UserName = "pikachiu"
MembershipUser member = System.Web.Security.Membership.GetUser(mbr_UserName);
string email = member.Email; // <-- am getting null here!?
//var member = umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(mbr_UserName); <!-- this one is considered Obsolete!?... }
}
}
But for some reason I am getting null pointer exception while accessing MembershipUser
And another Member.getMemberFromLoginName() method says it's obsolete... so not sure what to do here :(
Well yes, I have a Member with UserName "pikachiu".
Regarding
MembershipUser member =System.Web.Security.Membership.GetUserNameByEmail(mbr_Email);
you suggest here.
I am getting the same, I see that I am getting the instance of the member, the problem was that I could not call it's username (or in your case email - got the same issue) ... It needed to have .toString(); method, So when I called toString() on it, it actually works, but I wounder why it needs it, cause ".Email" is of type "string". So it works with .toString() for now...
But than here comes another part of the question - if I choose this approach how can I manage Member properties (like Age, Job, Phone for example...).
If instanciated a member and then called the GetUserNameByEmail method you should not have to cast.
You second question is the same problem i am going to come up against next week. There are quite alot of forum posts about it. There does not seem to be a problem manageing the propertys. Create some auto properties Age Job Phone ect and then there should be be a method of the member to assign these. The problem appears to be saving these values back to the database.
And than I intent to use something called "user profiles" (look in the buttom of the page in that link).
But at the same time I found this [http://www.aaron-powell.com/umbraco-members-profiles] thing here, lots of people discussed here
But the problem is - I don't see the way how can I edit users in from Member administration in Umbraco, cause there are only "username" and email password etc... but if user has a profile picture or googleLocation f.ex... how do I find a way to do that? Is that possible to do through admin pannel, or I have to write my own umbraco section to manage that?
When you are refering to users? Do you mean members?
Users: People who can use umbraco
Members: People who can log into the site.
In Umbraco you can add custom properties to a member, as you would with a datatype. Then you can interact with these using the member provider. Having never done this before its going to be something new for me as well. Will take a look at your resounces. Thanks. Charlei :)
Yea that web config way seems valid. I think i have read some people have had trouble with saving that information to the database. But the webconfig way is how i am going to approach it i think :)
That second link seems a bit of a suspect implimentation. I just feel there must be an easier way to do it :). Let me know what you find. Have a great evening too :) Charlie :)
Working with members in C#
Hej Guys,
This one should be quite easy...
I just downloaded newest umbraco 6.0 and playing arround with it...
So what I am having trouble with:
Pull out a member from all members by UserName.
Than access it's properties (f.ex. Name)
Than I want to add some other properties (like age, currentLocation and stuff like that...)...
For now I have this...
But for some reason I am getting null pointer exception while accessing MembershipUser
And another Member.getMemberFromLoginName() method says it's obsolete... so not sure what to do here :(
//Dmitrij
Edit:
in the line string mbr_UserName ="pikachiu"
I have ";" corrected... string mbr_UserName ="pikachiu";
Hey Dmitrij,
Have you checked that a member with the username called 'pikachiu' has been setup in Umbraco.
Also what do you get from: MembershipUser member =System.Web.Security.Membership.GetUserNameByEmail(mbr_Email);
I am presuming you are in the umbraco context and hitting the breakpoint?
Charlie. :)
Hej Charles :-)
Well yes, I have a Member with UserName "pikachiu".
Regarding
you suggest here.
I am getting the same, I see that I am getting the instance of the member, the problem was that I could not call it's username (or in your case email - got the same issue) ... It needed to have .toString(); method, So when I called toString() on it, it actually works, but I wounder why it needs it, cause ".Email" is of type "string". So it works with .toString() for now...
But than here comes another part of the question - if I choose this approach how can I manage Member properties (like Age, Job, Phone for example...).
Thanks for help :-)
//Dmitrij
Ah that would atcually make sense
If instanciated a member and then called the GetUserNameByEmail method you should not have to cast.
You second question is the same problem i am going to come up against next week. There are quite alot of forum posts about it. There does not seem to be a problem manageing the propertys. Create some auto properties Age Job Phone ect and then there should be be a method of the member to assign these. The problem appears to be saving these values back to the database.
Take a look at this post:
http://our.umbraco.org/forum/developers/api-questions/12348-member-profile-problem-45x?p=0#comment76619
Please let me know if you get a solution working :D Thanks. Charlie :)
Hehe :-)
I sure will try, I still look forward to discuss this toppic here until I get it done in the way how it's REALLY supposed to be done! :-)
For now I am sticking to this approach: http://our.umbraco.org/wiki/how-tos/membership-providers
And than I intent to use something called "user profiles" (look in the buttom of the page in that link).
But at the same time I found this [http://www.aaron-powell.com/umbraco-members-profiles] thing here, lots of people discussed here
But the problem is - I don't see the way how can I edit users in from Member administration in Umbraco, cause there are only "username" and email password etc... but if user has a profile picture or googleLocation f.ex... how do I find a way to do that? Is that possible to do through admin pannel, or I have to write my own umbraco section to manage that?
Have a great evening :-)
//Dmitrij
When you are refering to users? Do you mean members?
Users: People who can use umbraco
Members: People who can log into the site.
In Umbraco you can add custom properties to a member, as you would with a datatype. Then you can interact with these using the member provider. Having never done this before its going to be something new for me as well. Will take a look at your resounces. Thanks. Charlei :)
Yea that web config way seems valid. I think i have read some people have had trouble with saving that information to the database. But the webconfig way is how i am going to approach it i think :)
That second link seems a bit of a suspect implimentation. I just feel there must be an easier way to do it :). Let me know what you find. Have a great evening too :) Charlie :)
Hej again charles,
By using "users" I meant Members, and I totally agree with your terminology :-)
Cause the whole thing here is all about members :-)
well aniways... yea sure, I am still sticking to first approach (the correct one) but I am keeping another one just in case.
Let me know if you have some progress aswell :)))
Cheers,
//Dmitrij
Replied to this in the other topic :)
Hej Charls,
yes I see now... thanks for help mate :-)))
I will now try find some time and try actually going step by step in that article yous send me. (we both read last time)
Only difference now I really understand it... :-)
If any more problems will apear, I will let you know in that another post.
Thanks alot for help so far!!! :-)))
Regards,
Dmitrij
No problem :)
is working on a reply...