table = $table; $this->column = $column; $this->except_id = $except_id; } /** * Check the rule passed or not * * @param any $field * @param any $value * * @return bool */ public function passes( $field, $value ): bool { if ( $this->table === 'wp_users' ) { $existing_user = get_user_by( $field, $value ); if ( ! $existing_user ) { return true; } if ( intval( $existing_user->ID ) === intval( $this->except_id ) ) { return true; } return false; } return true; } /** * Set validation message * * @param any $field * * @return string */ public function message( $field ) { return $field . ' is not unique'; } }