AnsPress_Validation::length_check( string $field, string $param )

Description #

Check length of a string, if less then specified then return error

Parameters #

  • $field
    string (Required)
  • $param
    string (Required)

Changelog #

VersionDescription
2.0Introduced.

Source #

File: includes/class/validation.php

	private function length_check( $field, $param ) {
		// Dont check if Administrator.
		if ( current_user_can( 'manage_options' ) ) {
			return;
		}

		if ( $param != 0 && ( ! isset( $this->fields[$field] ) || mb_strlen( strip_tags( $this->fields[$field] ) ) <= $param ) ) {
			$this->errors[$field] = sprintf( __( 'Field value should be at least %d characters', 'anspress-question-answer' ), $param );
		}
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment