We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1343 ☆ A M B ☆
    • 2,213 Posts
    Hello,

    I’m in the process of setting my fire WLPE based site (well section of a site), but I was wondering if there is a way to show a message to users the first time or first two times they login? Also would there be any way to limit that based on a custom field or member group?

    Also anyone know if the bug that resets a user profile if you have custom fields has been fixed?

    Thanks
    AMDbuilder
      Patrick | Server Wrangler
      About Me: Website | Tweets |  MODX Hosting
      • 4041
      • 788 Posts
      You can access the number of times a user has logged in with $_SESSION[’webnrlogins’], the following snippet example checks if the $number_of_logins is less than or equal to the $max_logins, and if so it prints a message.. if not nothing shows.

      <?php
      if(isset($_SESSION['webShortname'])){
      $output ="";
      $number_of_logins =$_SESSION['webnrlogins'];
      $max_logins =2;
        if($number_of_logins <= $max_logins){
      // print the results
          $output .="You have logged in ".$number_of_logins." times";
         }
      
      return $output;
      }
      ?>
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 1343 ☆ A M B ☆
        • 2,213 Posts
        Thanks for the quick response!

        If I wanted to include a chunk or a TV would I just change the output:

            $output .="You have logged in ".$number_of_logins." times"; to
            $output .="{{chunkname}}";
        
        // or would I use and just drop the last two lines (except php tag)
        
            echo="{{chunkname}}";
        
        


        Thanks again,
        AMDbuilder
          Patrick | Server Wrangler
          About Me: Website | Tweets |  MODX Hosting
          • 1343 ☆ A M B ☆
          • 2,213 Posts
          Oh, forgot to check one more thing! (Trying to target two groups on the same page with different welcomes etc)

          If I wanted to provide an alternative for >2 logins would this be correct? (again chunk or tv output as per above post)

          <?php
          if(isset($_SESSION['webShortname'])){
          $output ="";
          $number_of_logins =$_SESSION['webnrlogins'];
          $max_logins =2;
            if($number_of_logins <= $max_logins){
          // print the results
              $output .="You have logged in ".$number_of_logins." times";
             } else {
              $output .="You have logged in ".$number_of_logins." times";
          }
          
          return $output;
          }
          ?>

            Patrick | Server Wrangler
            About Me: Website | Tweets |  MODX Hosting
            • 4041
            • 788 Posts
            Try this snippet:
            * change the 1 and 6 in these sections to the number of the group you want to check for:
            if(array_value_count("1",$_SESSION['webDocgroups'])){
            else if(array_value_count("6",$_SESSION['webDocgroups'])){

            * change the $max_logins to suit
            * modify the chunk name you want to print according to the group

            <?php
            /* Welcome_Message.snippet.php
                [!Welcome_Message!]
            */
            if(isset($_SESSION['webShortname'])){
            
            $number_of_logins =$_SESSION['webnrlogins'];
            
            function array_value_count ($match, $array)
            { 
                $count = 0;     
                foreach ($array as $key => $value) 
                { 
                    if ($value == $match) 
                    { 
                        $count++; 
                    } 
                }     
                return $count; 
            }
            
            $output ="";
            // this checks for webDocgroup with id #1
            // if its found, then it sets the output results
            if(array_value_count("1",$_SESSION['webDocgroups'])){
               $webgroup ="1";
               $max_logins ="500";
               $default_chunk ="Welcome_Message_1";
            }
            else if(array_value_count("6",$_SESSION['webDocgroups'])){
               $webgroup ="6";
               $max_logins ="2";
               $default_chunk ="Welcome_Message_2";
            }
            else{
               $webgroup ="No Web Groups";
               $max_logins ="100";
               $default_chunk ="";
            }
            
              if($number_of_logins <= $max_logins){
            // print the results if $default_chunk is not empty
                if($default_chunk !=""){
                  $output .="{{".$default_chunk."}}";
            
                  // debug output (uncomment to show)
                  // $output .="<br />
                  //                  <div>You have logged in ".$number_of_logins." times out of (".$max_logins.") and are a member of ".$webgroup."</div>";
                }
            }
            
            return $output;
            }
            ?>


            Note that if the webuser is a member of both groups you are checking for, I think it will take the last value you check for before processing.

            If you cant figure out the ID of the groups you are checking for, use this snippet on a page... log in as the webuser and check the array results for the ID’s which will show like this:
            [webDocgroups] => Array ( [0] => 1 )


            <?php
            /* Session_Info
                [!Session_Info!]
            */
            $output ="";
            if(isset($_SESSION['webShortname'])){
            $output .= print_r($_SESSION);
            }
            return $output;
            ?>
              xforum
              http://frsbuilders.net (under construction) forum for evolution
              • 28033
              • 925 Posts
              Quote from: AMDbuilder at Nov 13, 2008, 12:15 PM

              Also anyone know if the bug that resets a user profile if you have custom fields has been fixed?

              Thanks
              AMDbuilder

              AFAIK, no. I dunno why it does it, although I theorize that Scotty programmed it so the "default" fields are passed in even if they aren’t requested (since he probably never expected to have someone use the profile editor capabilities outside of the profile editor. And since they’re null when you do that, it’s passed in (also why you can pass them in via "hidden" commands in HTML and it doesn’t null them.

              For some reason my install also has a really weird issue when it comes to registering people normally (i.e., it adds them even if the password fields obviously don’t match, etc. etc.)...
                My Snippets
                -> PopUpChunk v1.0
                • 27330
                • 884 Posts
                AMD Builder does the snippet from Breezer worked for you as expected?
                  • 1343 ☆ A M B ☆
                  • 2,213 Posts
                  I’ve been sidetracked on other projects so I haven’t had a moment to try it.

                  I will report in once I test it.
                  AMDbuilder
                    Patrick | Server Wrangler
                    About Me: Website | Tweets |  MODX Hosting