none
sharepoint sites welcome page RRS feed

  • Question

  • i need to redirect the users to different url logging to the sites so please help me with the approach.

    I have more number of sites to be redirected ,if any automation available for this task.


    Blitz


    • Edited by sree_23 Monday, September 25, 2017 2:15 PM
    Monday, September 25, 2017 2:15 PM

All replies

  • Hi Blitz,

    As a workaround, you could write some JS code in the welcome page with SharePoint designer to get the current user. Then according the user information, you can redirect to the related URL.

    There is a demo below.

    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script type="text/javascript">
    var loginName;
    var id;
    var title;
    var email;
    var user;
    
    function onQuerySucceeded() {
        loginName=user.get_loginName();
        id=user.get_id();
        title=user.get_title();
        email=user.get_email();
        if(title=="System Account"){
            window.location.href="http://wakaka:17710/sites/common/SitePages/How%20To%20Use%20This%20Library.aspx";
        }
    }
    
    function onQueryFailed() {
        alert('error');
    }
    
    $(function(){
        var context = SP.ClientContext.get_current();
        user = context.get_web().get_currentUser();    
        context.load(user);
        context.executeQueryAsync(onQuerySucceeded,onQueryFailed);
       
    });
        
    </script>

    Notice put JS code in the tag of <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"></asp:Content > like picture below.

    There is another way. You could create a list and add users and related URLs in the list. Then loop in the list and redirect to the corresponding URL according to the current user by adding JS code in the welcome page.

    Best regards,

    Lee Liu


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com



    • Edited by Lee Liu Wednesday, September 27, 2017 1:41 AM
    • Proposed as answer by Dennis GuoModerator Thursday, September 28, 2017 9:00 AM
    Tuesday, September 26, 2017 10:28 AM