We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Is there a way to hide a chunk from certain user groups? i.e. I have several chunks in call-outs, one of which should only be displayed to specific groups.

    basically I would like to make that chunk part of a resource group, the same way you would associate a specific resource.

    any thoughts?

    -thanks
    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 26503
      • 620 Posts
      Anyone have any thoughts on this??
        *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

        Sean Kimball CLP, CLS.
        Technical Director / Sr. Developer | BigBlock Studios
        ._______________________________________________.
        Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
        27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
        phone/fax: 905-426-5525
        • 33968
        • 863 Posts
        Hey sean, don’t know any way to accomplish this using the manager but you could use a simple snippet to do this.

        To **show** the chunk only for a particular user group:

        [[!showChunk? &group=`GroupName` &chunk=`ChunkName`]]
        <?php
        return $modx->user->isMember($group) ? $modx->getChunk($chunk) : '';
        


        To **hide** the chunk only for a particular user group:

        [[!hideChunk? &group=`GroupName` &chunk=`ChunkName`]]
        <?php
        return $modx->user->isMember($group) ? '' : $modx->getChunk($chunk);
        
          • 26503
          • 620 Posts
          Hi Lucas;

          Thanks - wound up doing this:

          in My template:
          <div id="right-content">
          	  [[!If? &subject=`[[!getGroups]]` &operator=`==` &operand=`true` &then=`[[*CalloutPositionOne]]`]]
          	  [[*CalloutPositionTwo]]
          	  [[*CalloutPositionThree]]
          	  [[*CalloutPositionFour]]
          	  [[*CalloutPositionFive]]
          </div>	
          


          Then in the getGroups snippet:
          <?php
          	
          	$output = 'false';     
          	if($modx->user->isMember(array('Resident Group','Staff Group'))){
          		$output = 'true';
          	}
          
          return $output;
          


          Yes - this could be better/sexier - but the deadline is real tight!

          -thanks
          -sean
            *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

            Sean Kimball CLP, CLS.
            Technical Director / Sr. Developer | BigBlock Studios
            ._______________________________________________.
            Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
            27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
            phone/fax: 905-426-5525
            • 37044
            • 68 Posts
            I have a quick extension of this question - based around this thread as well (https://forums.modx.com/?action=thread&thread=32601)

            I have two member groups 'group-a' and 'group-b'

            I want to write a snippet that will ultimately do the do a php if else / or switch functionality. Lucas I know you have recommended the switch extra (http://modx.com/extras/package/switch) before.

            So I what I want to do is:

            if user is logged in and part of 'group-a' show 'chunk-a', if user is logged in and part of 'group-b' show 'chunk-b' else show 'chunk-default'

            I have tried a number of iterations but cant seem to get the syntax right

            Any help appreciated.

            ***SOLVED***
            The following by bobray does what I want
            <?php
            /* InGroup snippet */
            $output = "";
            if ($modx->user->isMember('groupA')) {
                $output = $modx->getChunk('chunk1');
            } else if ($modx->user->isMember('GroupB')) {
                $output = $modx->getChunk('chunk2');
            } else {
                $output = $modx->getChunk('chunk3');
            }
            return $output;

            OP here- https://forums.modx.com/thread/18807/change-the-contents-of-a-page-based-on-a-group-of-users#dis-post-408830

            Thanks. [ed. note: megasteve4 last edited this post 14 years, 8 months ago.]