We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30025
    • 32 Posts
    Can someone help me with the modx coding for a snippet I am trying to create with the following logic:

    If (user="logged in" & belongs to usergroup="Editors")
    {
      echo "Text to show would go here";
    }
    Else {
    
      echo "Different text";
    }


    The snippet would be on a page that is visible to everyone, but only an "editor" would be able to see the special content.

    Look forward to learning how to do this.
      • 30025
      • 32 Posts
      I solved my own issue after much research. Here is the snippet code.

      <?php
      if ($modx->hasPermission('custom_admin_nav_bar'))
      {
      $user = $modx->getUser('mgr');  
      $profile = $user->getOne('Profile');
      $fname = $profile->get('fullname');
      $output = $modx->getChunk('adminBar',array('username' => $fname));
      return $output;
      }
      else {
      }


      The code basically checks if the user has a permission in their ACL. It then gets the users fullname and sends it to a custom chunk. Basically if a user has access he can see a special admin bar at the top of the screen which welcomes him with his fullname.

      Hope this is helpful to someone.