Vortex-lattice pinning and critical current density in anisotropic high-temperature superconductors