• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum is for release discussion only. Discussions that do not relate specifically to the resource release should be discussed in another, more appropriate forum.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

'Stay logged in' checked automatically.

Vincent

Well-known member
#1
Hello, this is very simple, but yet useful modification :D

It makes the 'Stay logged in' checkbox be checked as default ;)


Do the following for the checkbox in the login bar:
Find in template: login_bar_form:
PHP:
                        <label for="ctrl_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_remember" tabindex="104" /> {xen:phrase stay_logged_in}</label>
Replace with:
PHP:
                        <label for="ctrl_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" checked="checked" id="ctrl_remember" tabindex="104" /> {xen:phrase stay_logged_in}</label>
Do the following for the checkbox at the login form:
Find in template: helper_login_form:
PHP:
                    <div><label for="ctrl_pageLogin_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" /> {xen:phrase stay_logged_in}</label></div>
Replace with:
PHP:
                    <div><label for="ctrl_pageLogin_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" checked="checked" id="ctrl_pageLogin_remember" /> {xen:phrase stay_logged_in}</label></div>
 

dutchbb

Well-known member
#7
Just make sure you tell users when they login at a public place, they need to manually log out afterwards. Otherwise there is some security risk involved.
 
#11
login_bar_form:
Code:
<xen:comment>
With Javascript enabled, this form will be moved at page init time,
with the command $('#login').appendTo('#loginBar .pageContent');

Note that all external auth checks need to be added to the conditional below
in order to set $eAuth = 1 if any external auth providers are available.
</xen:comment>

<xen:if is="{$xenOptions.facebookAppId}"><xen:set var="$eAuth">1</xen:set></xen:if>

<form action="{xen:link 'login/login'}" method="post" class="xenForm {xen:if $eAuth, 'eAuth'}" id="login" style="display:none">

    <xen:if hascontent="true">
        <ul id="eAuthUnit">
            <xen:contentcheck>
                <xen:if is="{$xenOptions.facebookAppId}">
                    <xen:require css="facebook.css" />
                    <li><a href="{xen:link register/facebook, '', 'reg=1'}" class="fbLogin"><span>{xen:phrase login_with_facebook}</span></a></li>
                </xen:if>
            </xen:contentcheck>
        </ul>
    </xen:if>

    <div class="ctrlWrapper">
        <dl class="ctrlUnit">
            <dt><label for="LoginControl">{xen:phrase your_name_or_email_address}:</label></dt>
            <dd><input type="text" name="login" id="LoginControl" class="textCtrl" tabindex="101" /></dd>
        </dl>

    <xen:if is="{$xenOptions.registrationSetup.enabled}">
        <dl class="ctrlUnit">
            <dt>
                <label for="ctrl_password">{xen:phrase do_you_already_have_account}</label>
                <div class="lostPassword"><a href="{xen:link lost-password}" class="OverlayTrigger OverlayCloser" tabindex="107">{xen:phrase forgot_your_password}</a></div>
            </dt>
            <dd>
                <ul>
                    <li><label for="ctrl_not_registered"><input type="radio" name="register" value="1" id="ctrl_not_registered" tabindex="102" />
                        {xen:phrase no_create_account_now}</label></li>
                    <li><label for="ctrl_registered"><input type="radio" name="register" value="0" id="ctrl_registered" tabindex="102" checked="checked" class="Disabler" />
                        {xen:phrase yes_my_password_is}:</label></li>
                    <li id="ctrl_registered_Disabler">
                        <input type="password" name="password" class="textCtrl" id="ctrl_password" tabindex="103" />
                    </li>
                </ul>
            </dd>
        </dl>
    <xen:else />
        <dl class="ctrlUnit">
            <dt>
                <label for="ctrl_password">{xen:phrase password}:</label>
            </dt>
            <dd>
                <input type="password" name="password" class="textCtrl" id="ctrl_password" tabindex="103" />
                <div class="lostPasswordLogin"><a href="{xen:link lost-password}" class="OverlayTrigger OverlayCloser" tabindex="107">{xen:phrase forgot_your_password}</a></div>
            </dd>
        </dl>
    </xen:if>

        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd>
                <input type="submit" class="button primary" value="{xen:phrase log_in}" tabindex="105" data-loginPhrase="{xen:phrase log_in}" data-signupPhrase="{xen:phrase sign_up}" />
                <label for="ctrl_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" checked="checked" id="ctrl_remember" tabindex="104" /> {xen:phrase stay_logged_in}</label>
            </dd>
        </dl>
    </div>

    <input type="hidden" name="cookie_check" value="1" />
    <input type="hidden" name="redirect" value="{$requestPaths.requestUri}" />
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />

</form>
helper_login_form:
Code:
<xen:if is="!{$visitor.user_id}">

<xen:container var="$hideLoginBar">1</xen:container>

<form action="{xen:link 'login/login'}" method="post" class="xenForm formOverlay" id="pageLogin">

    <xen:if hascontent="true">
        <div class="errorPanel"><span class="errors">
            <xen:contentcheck>{xen:raw $text}</xen:contentcheck>
        </span></div>
    </xen:if>

    <h2 class="textHeading">{xen:phrase log_in_or_sign_up}</h2>

    <dl class="ctrlUnit">
        <dt><label for="ctrl_pageLogin_login">{xen:phrase your_name_or_email_address}:</label></dt>
        <dd><input type="text" name="login" value="{$defaultLogin}" id="ctrl_pageLogin_login" class="textCtrl" /></dd>
    </dl>

<xen:if is="{$xenOptions.registrationSetup.enabled}">
    <dl class="ctrlUnit">
        <dt><label for="ctrl_pageLogin_password">{xen:phrase do_you_already_have_account}</label></dt>
        <dd>
            <ul>
                <li><label for="ctrl_pageLogin_not_registered"><input type="radio" name="register" value="1" id="ctrl_pageLogin_not_registered" />
                    {xen:phrase no_create_account_now}</label></li>
                <li><label for="ctrl_pageLogin_registered"><input type="radio" name="register" value="0" id="ctrl_pageLogin_registered" checked="checked" class="Disabler" />
                    {xen:phrase yes_my_password_is}:</label></li>
                <li id="ctrl_pageLogin_registered_Disabler">
                    <input type="password" name="password" class="textCtrl" id="ctrl_pageLogin_password" />
                    <div><label for="ctrl_pageLogin_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" /> {xen:phrase stay_logged_in}</label></div>
                </li>
            </ul>
        </dd>
    </dl>
<xen:else />
    <dl class="ctrlUnit">
        <dt><label for="ctrl_pageLogin_password">{xen:phrase password}:</label></dt>
        <dd>
            <input type="password" name="password" class="textCtrl" id="ctrl_pageLogin_password" />
            <div><label for="ctrl_pageLogin_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" checked="checked" id="ctrl_pageLogin_remember" /> {xen:phrase stay_logged_in}</label></div>
        </dd>
    </dl>
</xen:if>

    <xen:if is="{$captcha}">
        <dl class="ctrlUnit">
            <dt>{xen:phrase verification}:</dt>
            <dd>{xen:raw $captcha}</dd>
        </dl>
    </xen:if>

    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd>
            <input type="submit" class="button primary" value="{xen:phrase log_in}" data-loginPhrase="{xen:phrase log_in}" data-signupPhrase="{xen:phrase sign_up}" />
            <a href="{xen:link lost-password}" class="OverlayTrigger OverlayCloser">{xen:phrase forgot_your_password}</a>
        </dd>
    </dl>

    <xen:if is="{$xenOptions.facebookAppId}">
        <xen:require css="facebook.css" />
        <dl class="ctrlUnit">
            <dt></dt>
            <dd><a href="{xen:link register/facebook, '', 'reg=1'}" class="fbLogin"><span>{xen:phrase login_with_facebook}</span></a></dd>
        </dl>
    </xen:if>

    <input type="hidden" name="cookie_check" value="1" />
    <input type="hidden" name="redirect" value="{xen:if $redirect, $redirect, $requestPaths.requestUri}" />
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />

</form>

<script type="text/javascript">
    $(function()
    {
        var $button = $('#pageLogin input.button.primary');
        $('#pageLogin input[name="register"]').click(function()
        {
            $button.val(
                $('#pageLogin input[name="register"]:checked').val() == '1'
                ? $button.data('signupPhrase')
                : $button.data('loginPhrase')
            );
        });
    });
</script>
</xen:if>
 

Vincent

Well-known member
#12
login_bar_form:
Code:
<xen:comment>
With Javascript enabled, this form will be moved at page init time,
with the command $('#login').appendTo('#loginBar .pageContent');

Note that all external auth checks need to be added to the conditional below
in order to set $eAuth = 1 if any external auth providers are available.
</xen:comment>

<xen:if is="{$xenOptions.facebookAppId}"><xen:set var="$eAuth">1</xen:set></xen:if>

<form action="{xen:link 'login/login'}" method="post" class="xenForm {xen:if $eAuth, 'eAuth'}" id="login" style="display:none">

    <xen:if hascontent="true">
        <ul id="eAuthUnit">
            <xen:contentcheck>
                <xen:if is="{$xenOptions.facebookAppId}">
                    <xen:require css="facebook.css" />
                    <li><a href="{xen:link register/facebook, '', 'reg=1'}" class="fbLogin"><span>{xen:phrase login_with_facebook}</span></a></li>
                </xen:if>
            </xen:contentcheck>
        </ul>
    </xen:if>

    <div class="ctrlWrapper">
        <dl class="ctrlUnit">
            <dt><label for="LoginControl">{xen:phrase your_name_or_email_address}:</label></dt>
            <dd><input type="text" name="login" id="LoginControl" class="textCtrl" tabindex="101" /></dd>
        </dl>

    <xen:if is="{$xenOptions.registrationSetup.enabled}">
        <dl class="ctrlUnit">
            <dt>
                <label for="ctrl_password">{xen:phrase do_you_already_have_account}</label>
                <div class="lostPassword"><a href="{xen:link lost-password}" class="OverlayTrigger OverlayCloser" tabindex="107">{xen:phrase forgot_your_password}</a></div>
            </dt>
            <dd>
                <ul>
                    <li><label for="ctrl_not_registered"><input type="radio" name="register" value="1" id="ctrl_not_registered" tabindex="102" />
                        {xen:phrase no_create_account_now}</label></li>
                    <li><label for="ctrl_registered"><input type="radio" name="register" value="0" id="ctrl_registered" tabindex="102" checked="checked" class="Disabler" />
                        {xen:phrase yes_my_password_is}:</label></li>
                    <li id="ctrl_registered_Disabler">
                        <input type="password" name="password" class="textCtrl" id="ctrl_password" tabindex="103" />
                    </li>
                </ul>
            </dd>
        </dl>
    <xen:else />
        <dl class="ctrlUnit">
            <dt>
                <label for="ctrl_password">{xen:phrase password}:</label>
            </dt>
            <dd>
                <input type="password" name="password" class="textCtrl" id="ctrl_password" tabindex="103" />
                <div class="lostPasswordLogin"><a href="{xen:link lost-password}" class="OverlayTrigger OverlayCloser" tabindex="107">{xen:phrase forgot_your_password}</a></div>
            </dd>
        </dl>
    </xen:if>

        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd>
                <input type="submit" class="button primary" value="{xen:phrase log_in}" tabindex="105" data-loginPhrase="{xen:phrase log_in}" data-signupPhrase="{xen:phrase sign_up}" />
                <label for="ctrl_remember" class="rememberPassword"><input type="checkbox" checked="checked" name="remember" value="1" checked="checked" id="ctrl_remember" tabindex="104" /> {xen:phrase stay_logged_in}</label>
            </dd>
        </dl>
    </div>
helper_login_form:
Code:
<xen:if is="!{$visitor.user_id}">

<xen:container var="$hideLoginBar">1</xen:container>

<form action="{xen:link 'login/login'}" method="post" class="xenForm formOverlay" id="pageLogin">

    <xen:if hascontent="true">
        <div class="errorPanel"><span class="errors">
            <xen:contentcheck>{xen:raw $text}</xen:contentcheck>
        </span></div>
    </xen:if>

    <h2 class="textHeading">{xen:phrase log_in_or_sign_up}</h2>

    <dl class="ctrlUnit">
        <dt><label for="ctrl_pageLogin_login">{xen:phrase your_name_or_email_address}:</label></dt>
        <dd><input type="text" name="login" value="{$defaultLogin}" id="ctrl_pageLogin_login" class="textCtrl" /></dd>
    </dl>

<xen:if is="{$xenOptions.registrationSetup.enabled}">
    <dl class="ctrlUnit">
        <dt><label for="ctrl_pageLogin_password">{xen:phrase do_you_already_have_account}</label></dt>
        <dd>
            <ul>
                <li><label for="ctrl_pageLogin_not_registered"><input type="radio" name="register" value="1" id="ctrl_pageLogin_not_registered" />
                    {xen:phrase no_create_account_now}</label></li>
                <li><label for="ctrl_pageLogin_registered"><input type="radio" name="register" value="0" id="ctrl_pageLogin_registered" checked="checked" class="Disabler" />
                    {xen:phrase yes_my_password_is}:</label></li>
                <li id="ctrl_pageLogin_registered_Disabler">
                    <input type="password" name="password" class="textCtrl" id="ctrl_pageLogin_password" />
                    <div><label for="ctrl_pageLogin_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_pageLogin_remember" /> {xen:phrase stay_logged_in}</label></div>
                </li>
            </ul>
        </dd>
    </dl>
<xen:else />
    <dl class="ctrlUnit">
        <dt><label for="ctrl_pageLogin_password">{xen:phrase password}:</label></dt>
        <dd>
            <input type="password" name="password" class="textCtrl" id="ctrl_pageLogin_password" />
            <div><label for="ctrl_pageLogin_remember" class="rememberPassword"><input type="checkbox" checked="checked" name="remember" value="1" checked="checked" id="ctrl_pageLogin_remember" /> {xen:phrase stay_logged_in}</label></div>
        </dd>
    </dl>
</xen:if>

    <xen:if is="{$captcha}">
        <dl class="ctrlUnit">
            <dt>{xen:phrase verification}:</dt>
            <dd>{xen:raw $captcha}</dd>
        </dl>
    </xen:if>

    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd>
            <input type="submit" class="button primary" value="{xen:phrase log_in}" data-loginPhrase="{xen:phrase log_in}" data-signupPhrase="{xen:phrase sign_up}" />
            <a href="{xen:link lost-password}" class="OverlayTrigger OverlayCloser">{xen:phrase forgot_your_password}</a>
        </dd>
    </dl>

    <xen:if is="{$xenOptions.facebookAppId}">
        <xen:require css="facebook.css" />
        <dl class="ctrlUnit">
            <dt></dt>
            <dd><a href="{xen:link register/facebook, '', 'reg=1'}" class="fbLogin"><span>{xen:phrase login_with_facebook}</span></a></dd>
        </dl>
    </xen:if>

    <input type="hidden" name="cookie_check" value="1" />
    <input type="hidden" name="redirect" value="{xen:if $redirect, $redirect, $requestPaths.requestUri}" />
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />

</form>

<script type="text/javascript">
    $(function()
    {
        var $button = $('#pageLogin input.button.primary');
        $('#pageLogin input[name="register"]').click(function()
        {
            $button.val(
                $('#pageLogin input[name="register"]:checked').val() == '1'
                ? $button.data('signupPhrase')
                : $button.data('loginPhrase')
            );
        });
    });
</script>
</xen:if>
 
#20
I can't find this in login_bar_form:

Code:
<label for="ctrl_remember" class="rememberPassword"><input type="checkbox" name="remember" value="1" id="ctrl_remember" tabindex="104" /> {xen:phrase stay_logged_in}</label>
I'm on XF 1.1.0, maybe that's the reason...?