+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How do you extend the user details?

How do you extend the user details?

14 posts, 0 answered
  1. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    24 Aug 2010
    Link to this post
    I need to extended the user details of a visitor who registers on the site I am developing that is essentially a ticket request system.  What I need is to capture the username and password by means of a simple registration form - first name, last name, email address. 

    Once the person is logged in need to capture other details, such as telephone number, fax number, address, etc. and save this information. 

    I have had a look at the "Adding User Details" section of the Sitefinity user manual (p.163), but this just shows how to capture these details on the backend.  I need enable the user to save/edit their details on the front end using a webform. 

    So essentially I need to be able to store the additional contact (and other information) in a database table.  What is the best approach to do doing this?  I can't extend the telerik_Users table because after an upgrade chances are my changes will be overridden.

    One approach would be to create a separate Customers table to hold the additional information with a CustomerID as the primary key, and then a foreign key relationship to the telerik_Users table on the UserId column.  But that doesn't seem ideal. 

    Can anyone recommend a better solution? 
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Aug 2010
    Link to this post
    Hello Mark,

    You should first extend the users profiles by adding additional fields in the <profile> section in web.config. Then you can use the CreateUserWizzard.ascx control to create a public control for the desired purposes. This forum thread will help you achieve this: http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/adding-profile-items.aspx.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    24 Aug 2010
    Link to this post
    I'm not sure that is what I am after. 

    These are the steps I need to achieve:

    1.)  A user registers - first name, last name, email address, password
    2.)  Click on a link to purchase a ticket
    3.)  The user fills in a form to request a ticket - and admin has to approve the ticket request.  On the form the ticket details pre-populated (I have this data stored in database table) and the user has to fill in the missing fields (contact details, address, personal information) and then once they submit the form the details are stored in a database and an email is sent off to the admin notifying them of the ticket request.
    4.) I DON'T need the user to be able to manage their profile.  However, when the ticket request form loads I need to be able to pre-populate the first name, last name and email fields.

    I'm not sure the CreateUserWizzard.ascx will work in this scenario?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Aug 2010
    Link to this post
    Hi Mark,

    The user fills in a form to request a ticket - and admin has to approve the ticket request.

    You could create a custom module which will allow you to manage the user and ticket from the backend. CreateUserWizard control will help you only during the registration process, but it will not serve you any UI or another option to manage the user later.

    So, you will have a module or just a control that will be used to set true/false value in your database whether the user has been approved or not. If the user has been approved you will set the flag to 1 and send an email.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    24 Aug 2010
    Link to this post
    Yes, I will use a custom module to control the backend.  When a user submits a ticket request on the website using a form, a notification email will be sent to the admin, and then he/she will log in and administer the request.

    My only (original) question is how and where do I store the additional user-specific information?  The contact details are only captured and stored after the user is logged in - where do I store these fields?  Do I create separte table and refernce the UserId on the telerik_Users table?

    To reiterate, the registration process will only capture first name, last name, email and password.  The additional contact information is only captured and stored after they log in and submit a request for a ticket - i.e. the ticket request form asks them for their contact and personal details. 

    I will save the ticket information into a database table and then use a custom module to retrieve that information.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Aug 2010
    Link to this post
    Hello Mark,

    first name, last name,  are set/get through Profile provider. You can use ProfileBase class to do this.

    email, username  - are membership data. You can use Membership class and MembershipUser class.

    If you use the build in providers to persist users data then it goes to telerik_Users and elerik_UserMetaInfo tables.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    24 Aug 2010
    Link to this post
    So how would I retreive, for example, the customers favourite movie field that I store when they enter the ticket request form?

    Have you got example code or URL for using the built-in providers?
  8. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    24 Aug 2010
    Link to this post
    So, if I have this correct I can create custom fields in the web.config (e.g. <add name="FirstName"/>" and access them using the UserManager class?

    private void GetCurrentUserInfo()
    {
      
            var userProfile = Profile.GetProfile(UserManager.GetCurrentUserName());
      
                if (userProfile != null)
                {
                    FirstName.Text = userProfile.FirstName;
            LastName.Text = userProfile.LastName;
            FavouriteMovie.Text = userProfile.FavouriteMovie;
                }
      
    }

    But, what happens when I am creating a custom module and I was to display all ticket requests in a grid using LINQ, including the custom profile information.  What table would I query to get the custom information?
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Aug 2010
    Link to this post
    Hi Mark,

    1.Profile properties can be accessed by ProfileBase and ProfileCommon. Please refer to MSDN for more details. Another option is using ManagerProfile class.

    2. When you bind the RadGrid you do not have to query database table. You have to use the API.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    25 Aug 2010
    Link to this post
    1.) Thanks.

    2.) Sorry, but I don't understand this.  If I need to return all the ticket request orders, along with who ordered them and their contact and personal details, and list them in a grid, surely I will need to query the database to retrieve that ticket request details and the contact details.

    I appreciate that this must be second nature to you, but for someone starting out with SiteFinity and the Provider model, it's a bit daunting and now I am not even sure where to start.
  11. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    25 Aug 2010
    Link to this post
    What if, after creating custom profile properties in the web.config and editing /Admin/CmsAdmin/User.aspx, if I need to query the records in a datagrid to include my custom ticket request details along with user profile information, can I query the [telerik_UserMetaInfo] table to achieve this?
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Aug 2010
    Link to this post
    Hi Mark,

    1. Use ProfileBase and ProfileCommon

    2. Create a custom datalayer for retrieving data from [telerik_UserMetaInfo]

    3. Make direct SQL queries

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Mark
    Mark avatar
    13 posts
    Registered:
    05 Aug 2010
    25 Aug 2010
    Link to this post
    Thanks, let me try that.
  14. James Reategui
    James Reategui avatar
    22 posts
    Registered:
    14 Oct 2008
    08 Mar 2011
    Link to this post
    if you do the following does that do 3 seperate queries to the database?
    var userProfile = Profile.GetProfile(UserManager.GetCurrentUserName());
       
                if (userProfile != null)
                {
                    FirstName.Text = userProfile.FirstName;
            LastName.Text = userProfile.LastName;
            FavouriteMovie.Text = userProfile.FavouriteMovie;
                }

    I was using a query like this, may be useful to others, but then when I migrated to Entity framework it doesn't work anymore so I was looking into just using the ProfileManager class as a quick fix instead of trying to come up with a fancier linq query.
    using (Data.VSGEntities dc = new Data.VSGEntities())
    {
        var query = from u in dc.telerik_Users
        where u.UserId == this.UserId
        select new DataTransferObjects.UserSummaryDTO
        {
                Email = u.Email.ToLower(),
            LastName = u.telerik_UserMetaInfo.Where(t => t.PropertyName == "LastName").First().Text,
            ScreenName = u.telerik_UserMetaInfo.Where(t => t.PropertyName == "ScreenName").First().Text,
            AvatarUrl = u.telerik_UserMetaInfo.Where(t => t.PropertyName == "Photo").First().Text,
            FirstName = u.telerik_UserMetaInfo.Where(t => t.PropertyName == "FirstName").First().Text,
            Location = u.telerik_UserMetaInfo.Where(t => t.PropertyName == "Location").First().Text
        };
        _userInformation = query.First();
            CacheManager.SetCache(CacheCategory.UserInfo, this.UserName, _userInformation, 60);
    }

    Any ideas would be appreciated :)
Register for webinar
14 posts, 0 answered