We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10389
    • 11 Posts
    Hi,

    I need to run some customized php-code after the webloginPE snippets had verified that all the conditions on the posted data are fulfilled.
    Is there a special location where I can include the code, or a special parameter to include some further code?
    After reading a little bit in the webloginpe.class.php, I thought it might be possible to add the code at the end of the Register(…) function:

    $this->SessionHandler('destroy');
    $this->FormatMessage($this->LanguageArray[100].$modx->config['site_name']);
    include('customized_code.php'); //more code
    return 'success';


    Thanks for a feedback
    Yves
      • 34017
      • 898 Posts
      You would create a new plugin and call it via:

      OnWebSaveUser
      Invoked AFTER a user is saved to the DB. This is invoked in both Register() AND SaveUserProfile(). Parameters are ’mode’ (new | update) and ’user’ (an array of ALL the users attributes).
        Chuck the Trukk
        ProWebscape.com :: Nashville-WebDesign.com
        - - - - - - - -
        What are TV's? Here's some info below.
        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
        • 10389
        • 11 Posts
        Hi

        I have written some code to generate automatically the username out of two custom fields named "firstname" and "lastname"

        		// Generate username from firstname and lastname:		
        		if(isset($_POST['firstname']) && $_POST['firstname'] != '')
        		{
        			$firstname = $modx->db->escape($modx->stripTags($_POST['firstname']));
        		}
        		if(isset($_POST['lastname']) && $_POST['lastname'] != '')
        		{
        			$lastname = $modx->db->escape($modx->stripTags($_POST['lastname']));
        		}
        		//Contruct username with: first letter of firstname and the lastname without any whitespaces
        		//          1. char for firstname        last name with no whitespace            
        		$username = substr(trim($firstname),0,1).ereg_replace( ' +', '',trim($lastname));
        		//username to lowercase	
        		$username = strtolower($username);
        		//Check if username exists
        		$checkUsername = $modx->db->query("SELECT `id` FROM ".$web_users." WHERE `username`='".$username."'");
        		$limit = $modx->recordCount($checkUsername);
        		//if so, add a number at this end
        		$attachednumer = 1;
        		while($limit > 0)
        		{
        			$newusername = $username.$attachednumer;
        			$attachednumer++;
        			$checkUsername = $modx->db->query("SELECT `id` FROM ".$web_users." WHERE `username`='".$newusername."'");
        			$limit = $modx->recordCount($checkUsername);
        			$username = $newusername;			
        		}
        		//put the username to the right object variable
        		$this->Username = $username;