Conditional Home Page redirection based on the login user department

Steel Contributor

We have a sharepoint classic team , and i created a new modern page "OurCompany.aspx" and i set it as the home page for our site. then i added modern pages for each department; HR.aspx , IT.aspx, Finance.aspx , and so on..

 

now can i set a conditional home page, based on the login user department ? so if a user is inside the IT department login to the sharepoint root site "https://ourcompnay.sharepoint.com" then instead of being redirected to the site home page "OurCompany.aspx" to be redirected to "IT.aspx"??

9 Replies

You can only set permissions for the sites.

For example, The IT user can enter only the IT site but will get an Unauthorized Access message when trying to access another site.
There no are redirections in Sharepoint.


@quizhead wrote:

You can only set permissions for the sites.

For example, The IT user can enter only the IT site but will get an Unauthorized Access message when trying to access another site.
There no are redirections in Sharepoint.


ok thanks for the reply. but can we achieve this using coding or development approaches ?

I don't think so, as the websites in SharePoint are not designed like this, as far as I know.
You may however, just send the specific site link to a specific user instead of the homepage if it helps with the query.
Quizhed is correct, you need some custom code to achieve this functionality...basically:
(1) In a classic page, you can add the redirection code in a Content Editor / Script Editor WebPart
(2) For modern pages, you need either a SPFx WebPart that allows to inyect the redirection code or create a SPFx Extension
I wasn't correct as I said that I don't think that it can be achieved.
Sorry John and thank you Juan.

@Juan Carlos González Martín wrote:
Quizhed is correct, you need some custom code to achieve this functionality...basically:
(1) In a classic page, you can add the redirection code in a Content Editor / Script Editor WebPart
(2) For modern pages, you need either a SPFx WebPart that allows to inyect the redirection code or create a SPFx Extension

so you mean i will need to develop an SPFX web part , and then add the web part to our modern home page? and inside the SPFX i will need to retrieve the login user department, and do the redirection accordingly ?

I meant a SPFx Extension that makes the redirection
Will you please share redirection spfx extension code here. Thanks!