We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14999
    • 0 Posts
    I use revolution1

    the code does not work is that
    please respond with the correct code and running and only professionals MODx, the code is very simple is not productive to lose all this time.

    the code does not work and was posted by Bob Ray

    <? php
    / * * Snippet ingroup /
    $ output = "";
    if ($ MODx-> user-> isMember (’Group’)) {
    $ output = $ MODx-> GetChunk (’chunk1’);
    } Else if ($ MODx-> user-> isMember (’GroupB’)) {
    $ output = $ MODx-> GetChunk (’chunk2’);
    Else {}
    $ output = $ MODx-> GetChunk (’chunk3’);
    }
    return $ output;

    ?>

    also fails

    <?php

    $user =& $modx->user;

    if ($user->isMember(’membres’) {

    $output = $modx->getChunk(’membres’);

    } elseif ($user->isMember(’administrateurs’) {

    $output = $modx->getChunk(’administrateurs’);

    } elseif ($user->isMember(’employés’) {

    $output = $modx->getChunk(’employés’);

    } else {

    $output = $modx->getChunk(’offline’);

    }

    return $output;
    ?>

    thank you very much
      • 37044
      • 68 Posts
      Just as a point of reference and anyone else who might stumble across this your code *is* different to bobrays - whos I am assuming does work.

      Bobrays original code is below
      <?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;


      At a guess this "Else {}" in your code will probably fail

      OP here - https://forums.modx.com/index.php?topic=66816.0;wap2
        • 3749
        • 24,544 Posts
        All the user groups and chunk names have to exist and be spelled correctly (they're case sensitive).

        It's also possible that the accented characters are causing trouble. And if the user groups and member groups were just created, you may have to clear the site cache, flush permissions, and flush sessions before the code will work (and maybe clear browser cache and cookies as well).


        ---------------------------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
        MODx info for everyone: http://bobsguides.com/MODx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting