User Profile Configuration

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
2/24/2011 2:56:23 PM
Gravatar
Total Posts 76

User Profile Configuration

I have two questions.  I am having problems finding the answers.  I have created a feature and it runs great with the auto setup.  I also created a user profile.  How do I access the text in the user profile in my feature?  Can I show a completely different page if a user profile doesn't have anything in it?  What I mean is, lets say I have employee code under user profile (admin controlled).  I created a page that all of the features will be based on the employee code.  So if the user doesn't have a employee code, they should be either redirected to another page, or a generic page is shown and directions on how to get the employee code filled in.

I hope that makes sense,

Thank you

2/25/2011 7:07:26 AM
Gravatar
Total Posts 18439

Re: User Profile Configuration

Hi Jonathan,

At the bottom of this document:

http://www.mojoportal.com/userprofileconfiguration.aspx

it shows a code snippet of how to set or get a custom user profile property. Once you retrieve the property you can decide base don that whether to redirect.

Hope it helps,

Joe

ps: Many thanks for the beers! Much appreciated.

2/25/2011 7:38:39 AM
Gravatar
Total Posts 76

Re: User Profile Configuration

Your welcome for the beers. Thank you for all that you have done with MojoPortal.  I saw that code, but could not get it to work.  My first problem was that it didn't know what SiteUser was.  I had to add "using mojoPortal.Business" even though it was in the reference folder and in the web.config.  Not a big deal.  Now it doesn't know what "GetCurrentUser" is: 'mojoPortal.Web.SiteUtils' does not contain a definition for 'GetCurrentUser'.  I am using 2.3.6.2 MSSQL.

2/25/2011 7:48:02 AM
Gravatar
Total Posts 18439

Re: User Profile Configuration

In your custom project you need a reference to the mojoPortal.Web project under the references node, then add

using mojoPortal.Web;

Hope it helps,

Joe

2/25/2011 9:13:36 AM
Gravatar
Total Posts 76

Re: User Profile Configuration

I already had the mojoPortal.Web as a reference and under the "using".  I rebuild the entire solution, and it didn't work.  One thing I don't understand, I can't find "GetCurrentUser" anywhere in the solution.  Is that the correct method?

2/25/2011 9:52:08 AM
Gravatar
Total Posts 2239

Re: User Profile Configuration

Hi,

Declaring a 'using' is not enough. You need to add a reference to mojoPortal.Web projects in the References node of your project. This is explained in this video http://www.mojoportal.com/dev-series-3-custom-solution.aspx at about minute 6:30. Also, you can read about adding references here: http://msdn.microsoft.com/en-us/library/wkze6zky%28v=VS.100%29.aspx.

I believe the method you are looking for is SiteUtils.GetCurrentSiteUser.

If you haven't already, you may want to check out http://apidocs.mojoportal.com. It is a great reference.

HTH,
Joe D.

2/25/2011 10:03:52 AM
Gravatar
Total Posts 18439

Re: User Profile Configuration

My bad, the method is actually SiteUtils.GetCurrentSiteUser(), I've corrected the document.

Best,

Joe

2/25/2011 10:15:40 AM
Gravatar
Total Posts 76

Re: User Profile Configuration

Joe, 

Its no problem.  I am glad we were able to solve the "problem".  Thank you both.  Can we add the arguments for the GetProperty to the documentation.  I am not sure what "SettingsSerializeAs" is asking for.  It will not let me put just object someObject = siteUser.GetProperty("propertyName"); It wants siteUser.GetProperty(propertyName, SettingsSerializeAs);

Thanks.

2/25/2011 10:22:25 AM
Gravatar
Total Posts 18439

Re: User Profile Configuration

There is actually a more simple method you can use:

GetCustomPropertyAsString(propertyName);

all properties are really stored as strings and this method returns the string value. At one time I was looking at alternate ways to store them, so the overloads with extra params were for that but I kind of abandoned the idea of storing custom properties any way other than string so I added the more simple method.

I'll update the document with the newer method.

Best,

Joe

2/25/2011 11:53:18 AM
Gravatar
Total Posts 76

Re: User Profile Configuration

Thank Joe!  I hate to be a bother, but on the documentation you have GetPropertyAsString instead of GetCustomPropertyAsString, and no semi colons on two of the lines.

2/26/2011 7:53:20 AM
Gravatar
Total Posts 18439

Re: User Profile Configuration

fixed.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.