Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter zempachi

    (@zempachi)

    Hello,

    i try to adapt the existing code by adding, at the beginning of the method “user_profile_update_errors”, the following lines:

    $newpassword= $user->user_pass;
    if($newpassword == $user->user_login)
    	$errors->add( 'pass', __( '<strong>ERROR</strong>: New password cannot be the same as the username.' ), array( 'form-field' => 'pass1' ) );
    if($newpassword == $user->user_email)
    	$errors->add( 'pass', __( '<strong>ERROR</strong>: New password cannot be the same as the email.' ), array( 'form-field' => 'pass1' ) );
    if(($c = $this->GetPasswordLen()) != 0)
    	if(strlen($newpassword) < $c)
    		$errors->add( 'pass', sprintf(__('<strong>ERROR</strong>: New password must contain at least %d characters.'), $c), array( 'form-field' => 'pass1' ) );
    if($this->IsPolicyEnabled(self::POLICY_MIXCASE))
    	if(strtolower($newpassword) == $newpassword)
    		$errors->add( 'pass', __( '<strong>ERROR</strong>: New password must contain both uppercase and lowercase characters.' ), array( 'form-field' => 'pass1' ) );
    if($this->IsPolicyEnabled(self::POLICY_NUMBERS))
    	if(!preg_match('/[0-9]/', $newpassword))
    		$errors->add( 'pass', __( '<strong>ERROR</strong>: New password must contain numbers.' ), array( 'form-field' => 'pass1' ) );
    if($this->IsPolicyEnabled(self::POLICY_SPECIAL))
    	if(!preg_match('/[_\W]/', $newpassword))
    		$errors->add( 'pass', __( '<strong>ERROR</strong>: New password must contain special characters.' ), array( 'form-field' => 'pass1' ) );

    which gives :

    public function user_profile_update_errors($errors, $update, $user){
    	//Tests adapted from the method wp_authenticate_user()
    	$newpassword= $user->user_pass;
    	if($newpassword == $user->user_login)
    		$errors->add( 'pass', __( '<strong>ERROR</strong>: New password cannot be the same as the username.' ), array( 'form-field' => 'pass1' ) );
    	if($newpassword == $user->user_email)
    		$errors->add( 'pass', __( '<strong>ERROR</strong>: New password cannot be the same as the email.' ), array( 'form-field' => 'pass1' ) );
    	if(($c = $this->GetPasswordLen()) != 0)
    		if(strlen($newpassword) < $c)
    			$errors->add( 'pass', sprintf(__('<strong>ERROR</strong>: New password must contain at least %d characters.'), $c), array( 'form-field' => 'pass1' ) );
    	if($this->IsPolicyEnabled(self::POLICY_MIXCASE))
    		if(strtolower($newpassword) == $newpassword)
    			$errors->add( 'pass', __( '<strong>ERROR</strong>: New password must contain both uppercase and lowercase characters.' ), array( 'form-field' => 'pass1' ) );
    	if($this->IsPolicyEnabled(self::POLICY_NUMBERS))
    		if(!preg_match('/[0-9]/', $newpassword))
    			$errors->add( 'pass', __( '<strong>ERROR</strong>: New password must contain numbers.' ), array( 'form-field' => 'pass1' ) );
    	if($this->IsPolicyEnabled(self::POLICY_SPECIAL))
    		if(!preg_match('/[_\W]/', $newpassword))
    			$errors->add( 'pass', __( '<strong>ERROR</strong>: New password must contain special characters.' ), array( 'form-field' => 'pass1' ) );
    
    	$update = $update; // stops IDE from complaining -_-
    	if (!$errors->get_error_data('pass') && !$errors->get_error_data('expired_password'))
    		update_user_option($user->ID, self::OPT_NAME_UPM, time());
    }

    EDIT: thoses modifications should be added in the file wp-password-policy-manager.php.
    And the version of the pulgin is “0.2”

    Hello,
    i have the same problem on Windows (Version 1.5) and it’s clerary a problem of permission.
    The temp files (png and txt) are created with a chmod 0444 and 0440.
    Or this means no “write” permission. Then, it is impossible to delete those files (unlink).
    So the only solution is to set (really-simple-captcha.php)
    – “file_mode” = 0644 (line 70)
    – “answer_file_mode” = 0640 (line 73)

Viewing 2 replies - 1 through 2 (of 2 total)