I don't understand the nature of your question. This login field
already appears only on the homepage of forums and not in the other headers. You don't have to move it somewhere and surround it with the extra code. It's already working that way.
Except it appears on the message reply/topic form, but it should be there. It's miniBB feature that you can login and post a message at once.
All conditions can't be build in templates. Templates contain only static content and variables, BUT variable could be build dynamically. Here's some additional
topic to read.