We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15896
    • 80 Posts
    Hi all,
    first of all, sorry for my bad english. This is the first time I write something on this forum, although it’s many month I’m usign Modx. I’ve made some changes to the weblogin snippet.
    I’ve just put all messages shown to the user with webLoginAlert method in a file of constants. This file has the name of the language choosed by the user with the new optional argument &lang. This file has been placed under the language folder, under the weblogin folder. This way:
    -->assets
    -->snippet
    -->weblogin
    -->language
    -->english.php

    All messages in the core weblogin files have been replaced with these constants. So, the question is why to do this? Just because, now if someone want to translate these messages, can just create a file with the name of the language. Put it under the language folder. Copy and paste all the constants from the default english file to the new language file and translate them.
    After this i’ve added a field in the default websignup template for double email checking and the relative check in the php process. This is useful to prevent wrong email typing from the user. If you ask to a user to type 2 times the same email you can be almost sure that his/her email is right and he/she’ll receive the confirmation email. I’ve managed some forums in the past and this was the typical error 50% of users did. They type their own email wrong.
    That’s all.
    Here you have the zipped file with the core weblogin files changed, the weblogin frontpages as they are given with the simple website installation with an explaination about the &lang argument, and you’ll find the language folder with 2 files: english.php (the default one) and italian.php (my mother language).
    Bye all
      • 6726
      • 7,075 Posts
      Thanks a lot kimu for this most useful snippet (at least to us who deal with non-english speaking users).
      I’ll add french language when I got some time !

      I’ll test this and report smiley
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 15896
        • 80 Posts
        Thanks to you davidm. It’s nice to help someway.
        I find a little "bug" in the weblogin.common.inc.php file that prevent the [+surl+] placeholder to be correctly replaced.
        This is the original function code
        function webLoginSendNewPassword($email,$uid,$pwd,$ufn){
        		global $modx;
        		$mailto = $modx->config['mailto'];
        		$websignupemail_message = $modx->config['websignupemail_message'];	
        		$emailsubject = $modx->config['emailsubject'];
        		$emailsender = $modx->config['emailsender']; 
        		$site_name = $modx->config['site_name'];
        		$site_start = $modx->config['site_start'];
        		$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
        		// replace placeholders
        		$message = str_replace("[+uid+]",$uid,$message);
        		$message = str_replace("[+pwd+]",$pwd,$message);
        		$message = str_replace("[+ufn+]",$ufn,$message);
        		$message = str_replace("[+sname+]",$site_name,$message);
        		$message = str_replace("[+semail+]",$emailsender,$message);
        		$message = str_replace("[+surl+]",dirname(PHP_SELF),$message);
        		if(!mail($email, $emailsubject, $message, "From: ".$emailsender."\r\n"."X-Mailer: Content Manager - PHP/".phpversion())) {
        			return webLoginAlert(WL_ERRONSEND.$mailto,1);
        		}		
        		return true;
        	}
        

        This is the line that prevent the correct replacement
        $message = str_replace("[+surl+]",dirname(PHP_SELF),$message);

        All you can obtain is a dot "." or something like that
        For working properly it has to be substituted whith this code:
        function webLoginSendNewPassword($email,$uid,$pwd,$ufn){
        		global $modx;
                        //aggiungere questa linea
                        global $site_url;
        		$mailto = $modx->config['mailto'];
        		$websignupemail_message = $modx->config['websignupemail_message'];	
        		$emailsubject = $modx->config['emailsubject'];
        		$emailsender = $modx->config['emailsender']; 
        		$site_name = $modx->config['site_name'];
        		$site_start = $modx->config['site_start'];
        		$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
        		// replace placeholders
        		$message = str_replace("[+uid+]",$uid,$message);
        		$message = str_replace("[+pwd+]",$pwd,$message);
        		$message = str_replace("[+ufn+]",$ufn,$message);
        		$message = str_replace("[+sname+]",$site_name,$message);
        		$message = str_replace("[+semail+]",$emailsender,$message);
                        //modificare questa linea come segue
        		$message = str_replace("[+surl+]",$site_url,$message);
        		if(!mail($email, $emailsubject, $message, "From: ".$emailsender."\r\n"."X-Mailer: Content Manager - PHP/".phpversion())) {
        			return webLoginAlert(WL_ERRONSEND.$mailto,1);
        		}		
        		return true;
        	}
        


        These 2 lines
          global $site_url;
          $message = str_replace("[+surl+]",$site_url,$message);
        

        make the [+surl+] placeholder to be replaced with the correct site url in the confirmation email template.

        I’ve added these changes to the weblogin.common.inc.php file included in the zip file above. So downloading the zip file is all included.

        Ciao wink
        • I use UTF-8 encoding in my development, and in this context I had to add this lines before sending mail in [tt]weblogin.processor.inc.php[/tt] and in [tt]weblogin.common.inc.php[/tt] :

                      $header = "From: ".$emailsender."\r\n";
                      $header.= "X-Mailer: MODx Content Manager - PHP/".phpversion()."\r\n";
                      $header.= "Content-Type: text/plain; charset=".$modx->config['modx_charset']."\r\n";
                      $header.= "Content-Transfer-Encoding: 8bit\r\n";
          

          In addition have you suggested, the integration of this Weblogin version in replacement of the current one ?
            Ackwa - Web Design & Development agency | Tours - France | Follow me on Twitter...
            • 30111
            • 19 Posts
            Hi guys,

            I’ve worked for MODx community today by writting a french translation for this snippet...

            I don’t know if all words are correct for a website administrator but the aim is there  huh
            If anybody wants me to suggest something, don’t hesitate, just email me...

            Cheers

            Titi - new french webmaster but already MODx addicted  wink
              Titi - new french MODx user but interested in
              • 17802
              • 190 Posts
              Hello!
              Thanks for this, it seems to be just what I need ;-)
              If I can get it to work with my MODx installation (0.9.5) I will write a Dutch translation and post it here.
                Thanks for MODx - I love it!
                • 2912
                • 315 Posts
                This worked for me on Modx 0.9.6.

                Thanks!
                  BBloke
                  • 18878
                  • 210 Posts
                  Quote from: Gildas at Nov 22, 2006, 09:28 PM

                  I use UTF-8 encoding in my development, and in this context I had to add this lines before sending mail in [tt]weblogin.processor.inc.php[/tt] and in [tt]weblogin.common.inc.php[/tt] :

                              $header = "From: ".$emailsender."\r\n";
                              $header.= "X-Mailer: MODx Content Manager - PHP/".phpversion()."\r\n";
                              $header.= "Content-Type: text/plain; charset=".$modx->config['modx_charset']."\r\n";
                              $header.= "Content-Transfer-Encoding: 8bit\r\n";
                  

                  In addition have you suggested, the integration of this Weblogin version in replacement of the current one ?


                  Hello Gildas,

                  I am having the same problem with sign up emails. The special latin characters are not showing up correctly. I inserted the lines you suggested on both files, but the problem remains. Could you tell us where exactly do we have to insert this code?

                  Thanks!!

                  Mc