How to Show HTML Content on an Article to Only Internal Users

Display extra content (outside of the Article body) to certain users

Last Updated: February 10, 2023

What's in this article?

This Article shows you how you can show or hide entire HTML divs on an internal Article page based on if the user accessing the page is logged in or not.

You can leverage .status-private to determine if the Article is an internal Article and then show and hide content based on that.

Here is an example script that checks if the article is Internal (using .status-private) and then generates a feedback link that will only show to internal users that are logged into the Knowledge Library:

<script>
window.addEventListener('DOMContentLoaded', (event) => {
    var [insertVarName] = document.querySelector('.status-private');
    if (insertVarName) {
        var link = document.createElement('a')
        link.href = "https://ovationcxm.com";
        link.target = '_blank';
        link.innerHTML = 'Give us your feedback, please - Internal only!'
        internalFeedbackLink.appendChild(link)
    }
});
</script>


The internalFeedbackLink is then referenced in the HTML where you weant the link to appear.

<!-- BEGIN Internal Feedback-->
<div class="row" style="background: white; z-index: 1;">
    <div class="columns large-12" style="background: white;">
    <br>
        <div id="internalFeedbackLink" align="center";>
        </div>
   </div>
</div>
<!-- END Internal Feedback -->


This is just one example of how you can show specific content outside of the Article body only to authenticated users.


Help us improve. Was this article helpful?


Can't find what you're looking for? Submit an Article Request.