Thanks Lossendae, it is nicer to use the built in modx filter instead of the ’if’ snippet, which I wasn’t fully aware of before; but it is still not redirecting correctly to loginResourceId..
My login form template is based on the default and I found this hidden variable:
<input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
which I’ve just changed to:
<input class="returnUrl" type="hidden" name="returnUrl" value="[[~2]]" />
And now it is redirecting to the desired landing page.. I’m am a bit worried that this will cause problems later when I would like to redirect to a different context for some users

but at least it is working for now