We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hi, I have the latest version of WLPE and I have noticed something odd. If I go in to my user profile and safe some changes or just hit the save button without changes, it’s deleting the user image. I checked my manager error log and I have 3 pages of WLPE errors.

    Event Id:  	1  	Source:  	WebLoginPE - Snippet
     
    Date: 	20-Sep-2008 09:22 PM 	User: 	
     
    
    Redefining already defined constructor for class WebLoginPE
    
    Unknown document




    When I save my profile it’s deleting the image as I said and at the top it says all changes were saved but it displays Unknown document underneath this message. I have tried a simple call using the default templates and the error is still there and the image disappearing (being deleted)

    Here is my profile form

    [+wlpe.message+]
    	<div style="padding:20px 20px 20px 0px; margin: 0 auto;text-align:left;  line-height:25px">
    	<form enctype="multipart/form-data" id="wlpeUserProfileForm" action="[~[*id*]~]" method="post">
    
    				<h3>Hello [+user.fullname+] ([+user.username+])!</h3>
    				<p>Use this form to update your profile information</p>
    				<fieldset style="margin: 0 auto;border: 0px dashed rgb(85, 85, 85); padding: 20px; margin-bottom: 0px;margin-top:50px; text-align: left;">
    				<h3>Your Details</h3>
    		<p>	Full Name
          <label for="wlpeUserProfileFullName" class="regform">
    			<input id="wlpeUserProfileFullName"  type="text" name="fullname" value="[+user.fullname+]" />
    			</label></p>
    
    		<p>	Company
          <label for="wlpeUserProfilecompany" class="regform">
    			<input id="wlpeUserProfilecompany" type="text" name="company" value="[+user.company+]" />
    			</label></p>
    
    		<p>	Website
          <label for="wlpeUserProfilewebsite" class="regform">
    			<input id="wlpeUserProfilewebsite" type="text" name="website" value="[+user.website+]" />
    			</label></p>
    
    	<p>Email	<label for="wlpeUserProfileEmail" class="regform">
    			<input id="wlpeUserProfileEmail" type="text" name="email" value="[+user.email+]" />
    			</label></p>	
    			
    			<p>Date of birth (MM-DD-YYYY)	
          <label for="wlpeUserProfileDob" class="regform">
    			<input id="wlpeUserProfileDob" type="text" name="dob" value="[+user.dob+]" />
    			</label>	</p>
    			
    			<p>[+form.gender+]</p>
    </fieldset>
    
    
    
    <fieldset style="margin: 0 auto;border: 0px dashed rgb(85, 85, 85); padding: 20px; margin-bottom: 0px;margin-top:10px; text-align: left;">
    <h3>Address Details</h3>
    <p>Address Line 1<label for="wlpeUserProfileaddress1" class="regform">
    <input id="wlpeUserProfileaddress1" type="text" value="[+user.address1+]" name="address1"/>
    </label></p>	
    <p>Address Line 2<label for="wlpeUserProfileaddress2" class="regform">
    <input id="wlpeUserProfileaddress2" type="text" value="[+user.address2+]" name="address2"/>
    </label></p>	
    
    <p>Address Line 3	<label for="wlpeUserProfileaddress3" class="regform">
    <input id="wlpeUserProfileaddress3" type="text" value="[+user.address3+]" name="address3"/>
    </label></p>
    
    <p>County/State
          <label for="wlpeUserProfileState" class="regform">
    			<input id="wlpeUserProfileState" type="text" name="state" value="[+user.state+]" />
    			</label></p>
    <p>Post/Zip Code
    			<label for="wlpeUserProfileZip" class="regform">
    			<input id="wlpeUserProfileZip" type="text" name="zip" value="[+user.zip+]" />
    			</label></p>
    
    	<p>Country
    			[+form.country+]</p>
    			
    			</fieldset>
    
    <fieldset style="margin: 0 auto;border: 0px dashed rgb(85, 85, 85); padding: 20px; margin-bottom: 0px;margin-top:10px; text-align: left;">
    
    <h3>Contact Numbers</h3>
    	<p>Phone number
          <label for="wlpeUserProfilePhone" class="regform">
    			<input id="wlpeUserProfilePhone" type="text" name="phone" value="[+user.phone+]" />
    			</label></p>	
    
    	<p>Mobile number
    			<label for="wlpeUserProfileMobile" class="regform">
    			<input id="wlpeUserProfileMobile" type="text" name="mobilephone" value="[+user.mobilephone+]" />
    			</label></p>
    
    	<p>Fax number
          <label for="wlpeUserProfileFax" class="regform">
    			<input id="wlpeUserProfileFax" type="text" name="fax" value="[+user.fax+]" />
    			</label></p>	
    
    			</fieldset>
    			
    			
    		<fieldset style="margin: 0 auto;border: 0px dashed rgb(85, 85, 85); padding: 20px; margin-bottom: 0px;margin-top:10px; text-align: left;">
    	<h3>Logo & Signature</h3>
    		<div>	<img id="wlpeUserProfilePhotoImg" src="[+user.photo+]" alt="[+user.username+]" title="[+user.fullname+]" height="250" width="250" /></div>
    
    	<p>	User Photo</p>	
    <label for="wlpeUserProfilePhoto" id="wlpeUserPhotoLabel">User Photo
    			<input type="hidden" id="wlpeUserHiddenPhoto" name="userphoto" value="[+user.photo+]" />
    			<input id="wlpeUserProfilePhoto" type="file" name="photo" value="" />
    			</label>
    
    			<p id="wlpeUserProfilePhotoInfo" class="info">No bigger than 200kb. will be resized to 250 x 250.</p>
    
    	<p>Comment/Signature</p>
    			<label for="wlpeUserProfileComment" class="regform">
    			<textarea id="wlpeUserProfileComment" rows="8" cols="40" name="comment">[+user.comment+]</textarea>
    			</label>
    				</fieldset>	
    	
    			
    <fieldset style="margin: 0 auto;border: 0px dashed rgb(85, 85, 85); padding: 20px; margin-bottom: 0px;margin-top:10px; text-align: left;">
    				<h3>Change your password</h3>
    				<p>Leave blank if you do not want a new password.</p>
    
    	<p>New Password	</p>		<label for="wlpeUserProfilePassword" class="regform">
    				<input id="wlpeUserProfilePassword" type="password" name="password" value="" />
    				</label>
    
    	<p>New Password (confirm)	</p>		<label for="wlpeUserProfilePasswordConfirm" class="regform">
    				<input id="wlpeUserProfilePasswordConfirm" type="password" name="password.confirm" value="" />
    				</label>
    			</fieldset>
    
    [[MemberCheck? &groups=`Designers` &chunk=`designerStandards` ]]
    [[MemberCheck? &groups=`Designers` &chunk=`designerSoftware` ]]
    
    <fieldset style="margin: 0 auto;border: 0px dashed rgb(85, 85, 85); padding: 60px; margin-bottom: 0px;margin-top:0px; text-align: center;">
    			<button type="submit" id="wlpeSaveProfileButton" name="service" value="saveprofile">Save</button>
    			<button type="submit" id="wlpeProfileDoneButton" name="service" value="cancel">Done</button>
    			<button type="submit" id="wlpeProfileLogoutButton" name="service" value="logout">Logout</button>
    			<button type="submit" id="wlpeProfileDeleteButton" name="service" value="deleteprofile">Delete My Profile</button>
    		</fieldset>
    	</form>
    </div>


    The membercheck is there for a reason and it’s not in the default templates Tpl so it’s not effecting anything.
      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
      AugmentBLU - MODX Partner

      BLUcart - MODX Revolution E-Commerce & Shopping Cart
      • 28033
      • 925 Posts
      I had a similar issue when I called WLPE stuff outside of the profile editor. I wonder if this is related...
        My Snippets
        -> PopUpChunk v1.0
      • It’s bit of a bummer... I have loginpe working like a dream now (nearly LOL) and I just noticed this! I just tested it on my other site that is using an older version of your 1.31 and it’s doing it on there as well.

        Event Id: 1 Source: WebLoginPE - Snippet

        Date: 21-Sep-2008 01:17 AM User:


        Redefining already defined constructor for class WebLoginPE

        Unknown document

        Again, saving the profile without any changes just caused that and the user image has been deleted.
          Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
          AugmentBLU - MODX Partner

          BLUcart - MODX Revolution E-Commerce & Shopping Cart
        • I just tested the 1.30 original snippet and it does not delete the image on save...
            Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
            AugmentBLU - MODX Partner

            BLUcart - MODX Revolution E-Commerce & Shopping Cart
          • I narrowed the error down that causes the users image to delete on save.

            		foreach ($generalElementsArray as $field)
            		{
            			if ($field == 'photo')
            			{
            				if ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))
            				{
            					$_POST['photo'] = $this->CreateUserImage();
            					if (!empty($this->Report))
            					{
            						return;
            					}
            				}
            			}
            			if ($field == 'dob' && trim($_POST['dob'])!='') // for not format an empty date else date is 0 (01-01-1970)
            			{
            				$_POST['dob'] = $this->MakeDateForDb($_POST['dob']);
            			}
            			if ($field!='photo' || ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))) // for update db with value and blank value (except if the field is 'photo')
            {
            	// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
            	$charset='"'.$modx->config['modx_charset'].'"';
            	$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES, $modx->config['modx_charset'])))."'";
            }
            			{
            				// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
            				$charset=$modx->config['modx_charset'];
            				$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES, $modx->config['modx_charset']))).	"'";
            			}
            		}


            Somewhere in this piece of code causes the deletion. I don’t know which part as I replaced it with the original code and it is no longer deleting the user image.
              Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
              AugmentBLU - MODX Partner

              BLUcart - MODX Revolution E-Commerce & Shopping Cart
              • 28033
              • 925 Posts
              IIRC, it’s a bug where pixelchutes’s fix was included twice. It snuck into WLPE 1.3.1 by accident.
                My Snippets
                -> PopUpChunk v1.0
                • 32667
                • 38 Posts
                Yes I was having this issue. Soshite is correct and you can see where it is included twice. Remove the second reference.

                So change:
                if ($field!='photo' || ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))) // for update db with value and blank value (except if the field is 'photo')
                {
                	// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                	$charset='"'.$modx->config['modx_charset'].'"';
                	$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES, $modx->config['modx_charset'])))."'";
                }
                			{
                				// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                				$charset=$modx->config['modx_charset'];
                				$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES, $modx->config['modx_charset']))).	"'";
                			}


                to:
                if ($field!='photo' || ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))) // for update db with value and blank value (except if the field is 'photo')
                {
                	// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                	$charset='"'.$modx->config['modx_charset'].'"';
                	$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES, $modx->config['modx_charset'])))."'";
                }
                


                So change that and then verify that any edits to the profile do not reset the photo field to blank. Then try changing the image. It should change. But note that it uploads the file and names it after the user. So after the form says it updated you will see the old image until you refresh.

                Cheers
                  • 15001
                  • 697 Posts
                  Rosco > Hi, I have the latest version of WLPE and I have noticed something odd.
                  @Rossco: Because the versions may change over time, it’s always better to specify the version number.

                  Yes I was having this issue. Soshite is correct and you can see where it is included twice. Remove the second reference.
                  @Soshite and Wounderbeer > I don’t see this duplication in my version of WLPE 1.3.1.
                  Maybe this was corrected and the version number stayed.

                  What Soshite and Wounderbeer told does not suffice if you’re using a table with extended attributes. In that case, the snippet gets the photo field from the extended attributes table. If you don’t have this column in the extended attributes table and call the snippet with &type=`users` &service=`viewprofile`, it appends the "photo" in it.

                  This means that the "photo" field in the extended table must not be empty.
                  Else, [+view.photo+] won’t output anything on the user’s "view profile" page.

                  This also means that when editing a profile, "photo" must be added to the list of custom fields in the string passed to "&customFields". Else, the path to the photo won’t be stored in the "extended" table but only in the "web_user_attributes" and the "View profile" page won’t be able to display it.

                  So that the photo field is not erased in the "extended attributes" table, around line 940 of webloginpe.class.php, replace this:
                  // CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                  $extendedFieldValues[] = " `".$field."` = '".$modx->db->escape(stripslashes(trim($_POST[$field])))."'";

                  by
                  // CREDIT: Julien Rouiller (aka Altipoint) for the condition. 
                  // This is to prevent that the photo field is cleared when a table of extended attributes is used.
                  if ($field!='photo' || ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))) {
                  				
                     // CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                     extendedFieldValues[] = " `".$field."` = '".$modx->db->escape(stripslashes(trim($_POST[$field])))."'";
                  }


                  This worked for me.

                  One last thing. When editing your profile or that of another user, you use fields like:
                  <input type="hidden" id="wlpeUserHiddenPhoto" name="userphoto" value="[+user.photo+]" />
                  <input id="wlpeUserProfilePhoto" type="file" name="photo" value="[+user.photo+]" size="14" maxlength="256" />


                  Concerning the default value passed to type="file", it is ignored for security reasons. See for instance: http://www.cs.tut.fi/~jkorpela/forms/file.html.

                  As for the field "userphoto", I assume it updates the modx_web_users, maybe directly via MODx because I cannot find the any trace of "userphoto" in WLPE. (Or was this a column name in MODx older versions?)

                  Cheers.
                  • I write my own ajax login stuff for modx now... but thanks for your answer 2 years later LOL grin
                      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                      AugmentBLU - MODX Partner

                      BLUcart - MODX Revolution E-Commerce & Shopping Cart
                      • 15001
                      • 697 Posts
                      @Rossco: I found this discussion thread because I experienced similar problem. Then, I thought that my experience could be useful to other users. Even two years after you question, as I could not find the issue being addressed elsewhere in the forum. My message was more a contribution to the discussion than an answer. Regards.