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

Forums / Developing with Sitefinity / Customized content based on users roles

Customized content based on users roles

5 posts, 0 answered
  1. Mark
    Mark avatar
    24 posts
    Registered:
    16 Jun 2009
    09 Aug 2010
    Link to this post
    Hi,

    I want to create different home pages for logged in users that are dependant on a users role, so for example a user with a sales role would see different content from a a user logged in with a IT role. is there a way to do this? 

    Thanks,

    M
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Aug 2010
    Link to this post
    Hello Mark,

    You need to create a custom control similar to this one - Roles Selector and hiding control based on user's roles  where you have to hide the control content or the entire control as the sample shows.

    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
  3. Mark
    Mark avatar
    24 posts
    Registered:
    16 Jun 2009
    11 Aug 2010
    Link to this post
    Thanks that pointed me in the right direction.
  4. Joe Keller
    Joe Keller avatar
    48 posts
    Registered:
    07 Apr 2010
    27 Aug 2010
    Link to this post
    Mark,

    I was just about to ask the exact same question, did you come up with a solution to this?

    Thanks
    Joe

  5. Mark
    Mark avatar
    24 posts
    Registered:
    16 Jun 2009
    05 Sep 2010
    Link to this post
    Hi,

    Sorry for the delay.

    Not saying this was the best solution but it worked for us and it was quick.
    01.string role = UserManager.GetCurrentRoleProviderName();
    02.string[] roles = UserManager.GetCurrentUserRoles();
    03. 
    04.if (UserManager.IsCurrentUserInRole("member") && UserManager.IsCurrentUserInRole("candidate"))
    05.{
    06.    ASP.usercontrols_bsc_candidateandmember_userprofile_ascx UserProfileControl1 = new ASP.usercontrols_bsc_candidateandmember_userprofile_ascx();
    07.    UserProfileArea.Controls.Add(UserProfileControl1);
    08.}
    09.else if (UserManager.IsCurrentUserInRole("member"))
    10.{  
    11.    ASP.usercontrols_bsc_member_userprofile_ascx UserProfileControl1 = new ASP.usercontrols_bsc_member_userprofile_ascx();
    12.    UserProfileArea.Controls.Add(UserProfileControl1);
    13.}
    14.else if (UserManager.IsCurrentUserInRole("candidate"))
    15.{
    16.    ASP.usercontrols_bsc_candidate_userprofile_ascx UserProfileControl1 = new ASP.usercontrols_bsc_candidate_userprofile_ascx();
    17.    UserProfileArea.Controls.Add(UserProfileControl1);
    18.}
    19.else if (UserManager.IsCurrentUserInRole("visitor"))
    20.{
    21.    ASP.usercontrols_bsc_registered_userprofile_ascx UserProfileControl1 = new ASP.usercontrols_bsc_registered_userprofile_ascx();
    22.    UserProfileArea.Controls.Add(UserProfileControl1);
    23.}

Register for webinar
5 posts, 0 answered