XF 2.0 How to auto-check & hide "Stay logged in" on Login form?

rdn

Well-known member
HTML:
<xf:checkboxrow>
<xf:option name="remember" selected="true">{{ phrase('stay_logged_in') }}</xf:option>
</xf:checkboxrow>

This "xf:checkboxrow" is new to me. :unsure:
 
Remove that checkbox.
In src/XF/Pub/Controller/Login.php
find everything what looks like
PHP:
'remember' => $input['remember'] ? 1 : null
and set that to always 1.
Additionally, you could change your table to default the column to 1.
 
Well ... yes, but actually this is nonsense :)

This generates
HTML:
<input type="hidden" name="remember" value="Stay logged in" selected="true" />

Attribute selected does not make sense for a hidden field and the value does not make sense either; this just works because the string "Stay logged in" is not empty and thus evaluates to true if treated as bool.
 
Last edited:
  • Like
Reactions: rdn
Code patches are never a good idea unless absolutely necessary, it would certainly be better to go with a template modification
Code:
<xf:hiddenval name="remember">1</xf:hiddenval>
Yea, that would work aswell, but it would allow to set the value to 0 if someone wanted to. So depends on the OP how strict he wants to be. In this situation it wouldn't matter I guess, but generally.
 
  • Like
Reactions: rdn
Top Bottom