0
votes

How to switch Sharepoint 2010 depending on the logged in user?

an example :

I want to make "mycustompage.master" as master page for users in group "mysiteowners" and "v4.master" as master page for the rest of users.

thanks.

1

1 Answers

1
votes

To set the master page file, use the following code

protected override void OnPreInit(EventArgs e) 
{ 
    if(UserIsInMySiteOwners())
    {
        Page.MasterPageFile = "~/mycustompage.master";
    }
    else
    {
        Page.MasterPageFile = "~/v4.master";
    }

} 

(You'll have to define your own method to determine if the user is in "Mysiteowners")