The condition (3) implies that if $f\ne 0$, then $K^2=(-1)^pq^{_p}$, for you can apply this condition to $w=-1/(qz)$ in place of $z$.
Then, a necessary condition is that the group of isometries generated by $z\mapsto z+1$ and $z\mapsto -1/(qz)$ is discrete. See Beardon's book on hyperbolic geometry for criteria on this. It is only true for contably many values of $q$. Among them is $q=1$ in which case the group of isometries is $SL_2({\mathbb Z})/\pm 1$.