2 Replies Latest reply on Apr 27, 2017 10:50 PM by Jeff Shurtliff

    Check if user belongs to a security group using JavaScript

    Jeff Shurtliff

      Hi all,

       

      Does anyone know if it's possible to check whether or not a user belongs to a certain security group using JavaScript?

      We are wanting to display certain hyperlinks in an HTML widget only if a user belongs to a specific security group. (e.g. an "Employees" group, etc.)

       

      We are already using JavaScript to display different content depending on whether or not a user is logged in, as shown below, but I'm not sure how to do so when a user belongs to a specific security group.

       

      "use strict";

      $(function(){

          /**

           * If the user isn't logged in, they see a Login and Register button in the widget.

           * If they are logged in, they see other buttons.

           */

       

       

          var userid = window.parent._jive_current_user.ID;

          if(userid == "undefined" || userid < 1) {

        $(".register-login").show();

        $(".case-management-quick-link").hide();

       

       

          } else {

       

       

         

              // User is in the group       

              $(".register-login").hide();

              $('.js-fade-in').fadeIn();

              $(".case-management-quick-link").show();

       

       

              setTimeout(function(){

                  resizeMe();

              }, 500);

       

       

         

       

       

          }

          $("#iframe-login").on("click", function(){

             

              event.preventDefault();

              window.parent.document.getElementById('navLogin').click()

             

          });

      });

       

      Any ideas?