plugins/ProfileExtender/class.profileextender.plugin.php
public function UserModel_AfterSave_Handler($Sender) {
      // Confirm we have submitted form values
      $FormPostValues = GetValue('FormPostValues', $Sender->EventArguments);

      if (is_array($FormPostValues)) {
         $UserID = GetValue('UserID', $Sender->EventArguments);
         $AllowedFields = $this->GetProfileFields();
         $Columns = Gdn::SQL()->FetchColumns('User');

         foreach ($FormPostValues as $Name => $Field) {
            // Whitelist
            if (!array_key_exists($Name, $AllowedFields))
               unset($FormPostValues[$Name]);

            // Don't allow duplicates on User table
            if (in_array($Name, $Columns))
               unset($FormPostValues[$Name]);
         }

         // Update UserMeta if any made it thru
         if (count($FormPostValues))
            Gdn::UserModel()->SetMeta($UserID, $FormPostValues, 'Profile.');
      }
   }
public function UserModel_AfterSave_Handler($Sender) {
      // Confirm we have submitted form values
      $FormPostValues = GetValue('FormPostValues', $Sender->EventArguments);

      if (is_array($FormPostValues)) {
         $UserID = GetValue('UserID', $Sender->EventArguments);
         $AllowedFields = $this->GetProfileFields();
         $Columns = Gdn::SQL()->FetchColumns('User');

         foreach ($FormPostValues as $Name => $Field) {
            // Whitelist
            if (!array_key_exists($Name, $AllowedFields))
               unset($FormPostValues[$Name]);

            // Don't allow duplicates on User table
            if (in_array($Name, $Columns))
               unset($FormPostValues[$Name]);
         }

         // Update UserMeta if any made it thru
         if (count($FormPostValues))
            Gdn::UserModel()->SetMeta($UserID, $FormPostValues, 'Profile.');
      }
   }
public function UserModel_AfterSave_Handler ( $ Sender ) { // Confirm we have submitted form values $ FormPostValues = GetValue ( 'FormPostValues' , $ Sender -> EventArguments ) ; if ( is_array ( $ FormPostValues ) ) { $ UserID = GetValue ( 'UserID' , $ Sender -> EventArguments ) ; $ AllowedFields = $ this -> GetProfileFields ( ) ; $ Columns = Gdn :: SQL ( ) -> FetchColumns ( 'User' ) ; foreach ( $ FormPostValues as $ Name => $ Field ) { // Whitelist if ( ! array_key_exists ( $ Name , $ AllowedFields ) ) unset ( $ FormPostValues [ $ Name ] ) ; // Don't allow duplicates on User table if ( in_array ( $ Name , $ Columns ) ) unset ( $ FormPostValues [ $ Name ] ) ; } // Update UserMeta if any made it thru if ( count ( $ FormPostValues ) ) Gdn :: UserModel ( ) -> SetMeta ( $ UserID , $ FormPostValues , 'Profile.' ) ; } }
Save custom profile fields when saving the user.
Save custom profile fields when saving the user .