Show/hide Two WebParts based on usergroups in Landing page

1) Create custom Document Library (ex: Pages) break the permissions and assign NT authenticated Users as read permissions
2) Create Web Part Page on SharePoint site
2)      Give proper name for Landing Page(ex: Default.aspx) and select the "Pages" from Document Library dropdown
3) Add 2 Content Editor WebParts on created page
4) Assign the groups to First Content Editor WebPart as Taget Audience
5) In content Editor HTML source, add the id to DIV tag (ex: <div id="authenticatedContent"> we need to use this id in second content editor webpart script file for verifying length)
6) Open the Second Content Editor WebPart HTML Source and add the below script
<div id="noaccessmsg"></div>
<script language="javascript" src="/root/root/SiteAssets/js/jquery-1.7.2.min.js"></script><script type="text/javascript">

if ($("#authenticatedContent").length == 0){                               
    $('#noaccessmsg').html("No Access")
}</script>

thats it.........................All the best...........

Comments

Popular posts from this blog

SharePoint 2016 and 2019 Ports

Unlock the SharePoint site using Powershell command

PsConfig step by step /Configuration Wizard. “Upgrade Available” vs “Upgrade required”