Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Berdia 45 posts 67 karma points
    Nov 08, 2011 @ 00:47
    Berdia
    0

    Add custom fields and retrieve them from database

    Hi,

    I want to enhance a CreateUserWizard in Umbraco. Add several custom fields (f. name, l. name, tel etc) and save them either in members table or in a separate custom table in SQL.

    Could you please let me know if it is possible?

    I managed to add custom fields in Member Types but it does not give me the right result. First and the foremost problem is that I can't see where in database Umbraco saves custom field values so I can retrieve it.

    Thank you.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 08, 2011 @ 02:02
    Tom Fulton
    0

    Hi Berdia,

    Check out this blog post:  http://www.aaron-powell.com/umbraco-members-profiles

    This is the method I always use to add custom fields to members and access them via a custom class.  It works well for me.  In the createuserwizard usercreated event I set any custom properties.

    I think you could also access the properties with the Member API similar to the way you access a Document's properties (m.getProperty("firstName").Value), but I think that's obsolete.

    Hope that helps,
    Tom

  • Barry Fogarty 493 posts 1129 karma points
    Nov 08, 2011 @ 02:25
    Barry Fogarty
    1

    Hi Berdia,

    Another good resource is http://umbraco.miketaylor.eu/2010/08/29/authenticating-new-members/

    This takes you through a step-by-step setup of a typical member site - with all the usual login and sign up features as well as custom profile fields.

    It is all based on the ASP.Net Membership system so you can use the server controls if you wish.

    Cheers
    Barry

  • Berdia 45 posts 67 karma points
    Nov 08, 2011 @ 11:25
    Berdia
    0

    Tom, Barry

    Thank you for your interesting comments. I will check both links and let you know how it goes. Although, there is one thing I wanted to ask you. As I see from a quick look at both posts user information is retrieved using API. There is nothing said whether it is recorded in SQL database or not. The reason I am asking is, there will be a desktop application which will need to talk and share data with my web application through database. Users I register through my Umbraco based web application need to be shared with desktop application and show up on the other end. So as you understand sharing data through SQL DB is important.

    I wanted to find out, is there a way to register and then retrieve user data from SQL DB which I am using for Umbraco? Something like, creating a new table and inserting additional user information there?

    Thank you.

    Berdia

  • Barry Fogarty 493 posts 1129 karma points
    Nov 08, 2011 @ 11:56
    Barry Fogarty
    0

    Membership data is stored in the SQL DB.  You have 2 options

    1. Include the Umbraco DLLs in your desktop project so you can connect to the website DB and use the API to retrieve member info
    2. Set up an external ASP.Net membership DB that can be shared by both applications

    I have not seen an example of 2 anywhewre but it should not be a problem - Umbraco membership is fully compatible with standard ASP.Net membership, so it will just be a case in your web.config to define the MembershipProvider to point to your external DB.  For instance, in your connections section you could have an entry like so:

    <add name="MyMembershipConn" connectionString="server=.\SQLEXPRESS;database=MyMemberDB;trusted_connection=True" providerName="System.Data.SqlClient"/>

    and then down in your membership section, your provider defined as

    <add name="SqlServerMembershipProvider" connectionStringName="MyMembershipConn" requiresQuestionAndAnswer="false" applicationName="MyMemberApp" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

    Personally I would go for #1 if there is a tight corelation between the systems, and definitely if the desktop app needs to access other site data (like content, nodes etc).  #2 should definitely be possible and would be interesting to know how you get on with it!  It would be more suited to a system where the 2 apps are quite separate but simply need to store the same member system.
           

  • Berdia 45 posts 67 karma points
    Nov 08, 2011 @ 13:01
    Berdia
    0

    Barry,

    Thank you for explaining it. I thought going for option 2 in the beginning as I already have everything set up and working, just need to migrate into Umbraco. Project I did is on ASP.NET and I am trying to build it on Umbraco.

    I am very interested how option 2 works too. I will try and let you know how it goes.

    Thank you for your help.

    Berdia 

  • Barry Fogarty 493 posts 1129 karma points
    Nov 17, 2011 @ 11:41
    Barry Fogarty
    0

    Hi Berdia,

    Just wondering how you went with this.  I am also working on a similar system and I have the basic member registration and login working from an external (ASP.Net membership) DB - but I have not got Profile to work as yet (adding extra profile fields like Name, Phone etc)

  • Berdia 45 posts 67 karma points
    Nov 17, 2011 @ 16:14
    Berdia
    0

    Hi Barry,

    I was working on it yesterday. I am getting the following error message (error on line 44):

    Unable to find the requested .Net Framework Data Provider. It may not be installed.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.

    Source Error:

    Line 42: 
    Line 43:             DataSource.InsertParameters.Add("UserId", UserGUID.ToString());
    Line 44: DataSource.Insert(); Line 45: 
    Line 46:             //Insert Checkbox values

     

    I am trying to find the reason but no luck yet. Meantime it is registering user in ASP.NET membership User table ok but does not register any extra field details into the DB. Must be because of above error.

    Please let me know if error is familiar to you. I will continue working on it this afternoon and will keep you posted how it goes.

    Berdia

     

  • Berdia 45 posts 67 karma points
    Nov 30, 2011 @ 22:38
    Berdia
    0

    Hi Barry,

    I managed to integrate ASP.NET membership service to Umbraco. Works fine. Let me know if you managed to do it or need help.

    Berdia

  • ggesheva 15 posts 116 karma points
    May 27, 2020 @ 13:06
    ggesheva
    0

    Hey Berdia,

    Can you please drop some snippets, I am trying to achieve the same thing but I am facing some difficulties with the whole approach.

Please Sign in or register to post replies

Write your reply to:

Draft