We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    I noticed in 0.9.6.3-RC2 as soon as you login to manager there is that message that reads something like "since this is the first time you log in ...." that disappear after I click the save settings button.

    Is there anyway I can display something similar to web users on first logon? like encourage them to change their password?
      • 4041
      • 788 Posts
      You could also do it with a snippet that checks the $_SESSION[webnrlogins] for that user:

      (code removed - see my next post below)
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 27330
        • 884 Posts
        thanks both for the replies.
        Breezer for some reason the message appears sometimes and sometimes not? (different users and I reset the login count in the db) anyway, isn’t the $_SESSION checks the current session? I mean if the user logs in after 2 months again he is going to see the same message even though its not his first login no?

        maybe it’s just the hour here. time for bed.

        Also before seeing your reply I tried doing something along ganeshXL recommendation. I’m in no way even closer to know what I’m doing but I scrapped this plugin (which doesn’t work btw..)

        is this anyway close to a workable plugin or am I way too far? smiley any input appreciated...


        <?php
        /*
         * prompt to change password on first login 
         * Display a message if this is the  
         * first time a web user is logged in
         *
         * Configuration:
         * &MessageChunk=Chunk to display;
         * Event:
         * check the OnWebLogin event
         */
        
        global $content;
        
        // Get a reference to the event
        $e = &$modx->Event;
        
        switch($e->name) {
          case 'OnWebLogin':
          
         // check the db to see if this is the first time a web user logs in 
        	$table = $modx->getFullTableName('web_user_attributes');
        	$result = $modx->db->select("logincount", $table, "1");
        	
        	if ($result =="1") {
        	echo $modx->getChunk('$MessageChunk');
        	}
        	
            break;
        default :
        return; // stop here - this is very important.
         break;
        }

        admin note: code tags added
          • 4041
          • 788 Posts
          ok, the previous snippet (removed from post above) had flawed logic smiley
          This one works every time, make sure its called uncached.

          <?php
          // 1st login message
          $output ="";
           
          if(isset($_SESSION[webShortname]) && $_SESSION[webnrlogins] < 1){
            //$output .="{{ChunkNameHere}}";
           $output .="<div>Please change your password asap :)</div>";
          }else{
            $output .="";
          }
           
          return $output;
          ?>


          Apparently the $_SESSION variables are set before the logincount is added to, so initial first login is count(0).
            xforum
            http://frsbuilders.net (under construction) forum for evolution