We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    I was trying on revo 2.1.1 and the latest login-snippet.

    For dubugging you can try this:

     
    
    <?php
    
    if (isset($redirs)){
        $redirs=explode(',',$redirs);
        if (count($redirs)>0){
            foreach ($redirs as $redir){
          
              $redir=explode(':',$redir);
                  
                if (count($redir)==2){
                    $ismember='no';          
                    if ($modx->user->isMember($redir[0])){
                        $url=$modx->makeUrl($redir[1]);
                        $ismember='yes';
                    }
                   $out .= $redir[0].':'.$ismember.'<br />';         
                }
            }
        }
    }
    
    if ($debug){
        return $out;
    }
    
    return  $modx->sendRedirect($url);


    [[!redirectUsergroups? &redirs=`iga-general:114,Testuser:8`&debug=`1`]]


      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 34108
      • 66 Posts
      Hi Bruno, thanks for your help! Have got it working now, there were two problems: the snippet call I was using was wrong (I was calling a user, not a usergroup), and our PHP developer also found a problem with the snippet itself (don’t know what exactly sorry, I can found out if you if you want). I’ve posted my final working code below.

      Snippet call
      [[!redirectUsergroups? &redirs=`IGA Everyday:108`]]


      Snippet - redirectUsergroups
      <?php
      /**
       * FormIt
       *
       * Copyright 2009-2010 by Bruno Perner <[email protected]>
       *
       * redirectUsergroups is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License as published by the Free
       * Software Foundation; either version 2 of the License, or (at your option) any
       * later version.
       *
       * redirectUsergroups is distributed in the hope that it will be useful, but WITHOUT ANY
       * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
       * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
       *
       * You should have received a copy of the GNU General Public License along with
       * redirectUsergroups; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
       * Suite 330, Boston, MA 02111-1307 USA
       *
       * @package redirectUsergroups
       */
      /**
       * redirectUsergroups
       *
       * Redirect Users of specified groups to specified Resources
       *
       * Example:
       *
       * [[!redirectUsergroups? &redirs=`Frontenduser:3||Testuser:8`]]
       *
       */
      
      
      if (isset($redirs)){
          $redirs=explode(',',$redirs);
      
          if (count($redirs)>0){
              foreach ($redirs as $redir){
      
                $redir=explode(':',$redir);
                  
                  if (count($redir)==2){
                      if ($modx->user->isMember($redir[0])){
                          $url=$modx->makeUrl($redir[1]);
                      }            
                  }
              }
          }
      }
      return  $modx->sendRedirect($url);
      
        • 18174
        • 116 Posts
        Hi Bruno

        You might have an idea to combine your snippet with a template variable for easier administration of the redirs parameter, don't you?
        In my case I probably have more than 50 redirs to handle. Would you recommend MIGX for this?

        Best regards
        manu [ed. note: manu37 last edited this post 13 years, 5 months ago.]
          • 36924 ☆ A M B ☆
          • 298 Posts
          Seems Bruno abandoned this project. But I hope hstee's notes will keep this beautiful constantly relevant
            • 36924 ☆ A M B ☆
            • 298 Posts
            Thought this snippet failed initially but I realized if the User account belongs to two different Usergroups with different permission level, the highest permission level takes precedence. [ed. note: ojchris last edited this post 12 years, 11 months ago.]