We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29357
    • 35 Posts
    I have posted this to the main boards then discovered this thread. Some WebloginPE events are broken (for SMF connector anyway) and I have fixed them as below:

    I have a large site with and smf forum and at least 80 different user groups. More of that in another post. Each one has to login and I like the features of WebloginPE. So you can imagine my consternation when logging in appeared to work...but didnt. I was logged in to the Modx side but not the SMF side where I was a blank. It took me a while to find this one..

    WebloginPE like weblogin invokes an OnWebLogin event. The SMF Connector uses it. Bit unlike Weblogin, WebloginPE passed an array of arrays. SMF was expecting an array with username in it. I dont know why WebloginPE is different but nomatter. I just tacked username onto the array like so. File is assets/snippets/webloginpe/webloginpe.class.php

    About 2996
    	function OnWebLogin()
    	{
    		global $modx;
    		$parameters = array('user' => $this->User,'username' => $this->User['username']);
    		$modx->invokeEvent('OnWebLogin', $parameters);
    	}



    Then came OnWebLogout...in this case WebloginPE got it completely wrong. It destroyed the session variables before trying to pass them in OnWebLogout.

    So I added this to function logout

    about 292

    	function Logout($type, $loHomeId = '')
    	{
    		$logoutparameters = array(
    			'username'		=> $_SESSION['webShortname'],
    			'internalKey'	=> $_SESSION['webInternalKey'],
    			'userid'		=> $_SESSION['webShortname']			
    			);
    	



    And this for the OnWebLogout function (old code commented out)

    about 3098

    	function OnWebLogout($logoutparameters)
    	{
    		global $modx;
    		//$paramaters = array(
    			//'userid'		=> $_SESSION['webInternalKey'],
    			//'internalKey'	=> $_SESSION['webInternalKey'],
    			//'username'		=> $_SESSION['webShortname']
    		//	);
    		$modx->invokeEvent('OnWebLogout', $logoutparameters);
    	}



    Good Luck
      • 29357
      • 35 Posts
      Sorry I forgot the OnWebSaveUser and OnWebDeleteUser events

      The fact is that Scotty must have assumed that nobody used these events and redefined them. Snag is that the smf connector certainly did use them and expected them to work!!

      The event as defined in save_web_user_processor was quite different and that’s what the smf connector was looking for

      So here is more:

      webloginpe.class.php

      Approx 3046 (note I left the $user array in there for compatibility with anything PE might use it for)

      	function OnWebSaveUser($mode = 'new', $user = array(), $username = '', $useremail='', $oldusername='', $olduseremail='')
      	{
      		global $modx;
      
      		$parameters = array(
      			'mode'	=> $mode,
      			'user'	=> $user,
      			'username' => $username,
      			'oldusername' => $oldusername,
      			'useremail' => $useremail,
      			'olduseremail' => $olduseremail
      			);
      		$modx->invokeEvent('OnWebSaveUser', $parameters);
      	}


      About 646
      		// EVENT: OnWebSaveUser
      		$this->OnWebSaveUser('new', $NewUser, $username , $useremail);
      
      

      About 954
      $this->OnWebSaveUser('update', $this->User, $username, $useremail, $_POST['oldusername'], $_POST['olduseremail']);
      



      about 993
      		function RemoveUserProfile()
      	{
      		global $modx;
      		
      		$currentWebUser = $modx->getWebUserInfo($modx->getLoginUserID());
      		$internalKey = $currentWebUser['internalKey'];
      		$this->RemoveProfile($internalKey);
      		$this->OnWebDeleteUser($internalKey, $currentWebUser['username']);
      		$this->SessionHandler('destroy');
      		$this->FormatMessage($this->LanguageArray[102]);
      		return;
      	}
      

      about 966
      	function RemoveProfile($internalKey)
      	{
      		global $modx;
      		//$deletedUser = $modx->getWebUserInfo($internalKey);
      		$web_users = $modx->getFullTableName('web_users');
      		$web_user_attributes = $modx->getFullTableName('web_user_attributes');
      		$web_groups = $modx->getFullTableName('web_groups');
      		$active_users = $modx->getFullTableName('active_users');
      		$deleteUser = $modx->db->query("DELETE FROM ".$web_users." WHERE `id`='".$internalKey."'");
      		$deleteAttributes = $modx->db->query("DELETE FROM ".$web_user_attributes." WHERE `internalKey`='".$internalKey."'");
      		$deleteFromGroups = $modx->db->query("DELETE FROM ".$web_groups." WHERE `webuser`='".$internalKey."'");
      		$deleteFromActiveUsers = $modx->db->query("DELETE FROM ".$active_users." WHERE `internalKey`='-".$internalKey."'");
      		
      		if (!$deleteUser || !$deleteAttributes || !$deleteFromGroups || !$deleteFromActiveUsers)
      		{
      			return $this->FormatMessage($this->LanguageArray[13]);
      		}
      
      		return;
      	}