1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.
    Dismiss Notice
  3. 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.

Discussion in 'Template Modifications [Archive]' started by Vincent, Oct 12, 2010.

  1. Vincent

    Vincent Well-Known Member

    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>
     
    Helladen, Forum, Peace and 25 others like this.
  2. borbole

    borbole Well-Known Member

  3. Vincent

    Vincent Well-Known Member

    Thanks, not that difficult though ;)
     
  4. borbole

    borbole Well-Known Member

    Well, it is not about the difficulty or size but quality and this modification has it :)
     
    Jeremy, laztrix and Vincent like this.
  5. yavuz

    yavuz Well-Known Member

    Wisely said, if you know what I mean :D
     
    borbole likes this.
  6. giminei

    giminei Member

    this mode dont work with the WHISPER style, can someone confirm?
     
  7. dutchbb

    dutchbb Well-Known Member

    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.
     
    Vincent likes this.
  8. Vincent

    Vincent Well-Known Member

    You just gotta add 'checked="checked"' somewhere in the checkbox code :)

    I'll think of a nice way to do this :D
     
  9. giminei

    giminei Member

    What do you mean with Checkbox Code? I did everything as described above. :/
     
  10. Vincent

    Vincent Well-Known Member

    Paste the whole template you want to make the edit in here.
     
  11. giminei

    giminei Member

    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>
     
  12. Vincent

    Vincent Well-Known Member

    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>
     
  13. giminei

    giminei Member

    it still does not work! its maybe because i have a private forum?
     
  14. Vincent

    Vincent Well-Known Member

    You must be doing something wrong. It's impossible this doesn't work.

    Feel free to send me a pm with a temp admin account
     
  15. giminei

    giminei Member

    thank you for the help, i have sent you a pm.
     
  16. DSF

    DSF Well-Known Member

    Thanks for this useful modification. ;)
     
    Vincent likes this.
  17. Sylar

    Sylar Well-Known Member

    I guess I forgot to thank you for this. Great little snippet mate, thanks. :)
     
    Vincent likes this.
  18. Vincent

    Vincent Well-Known Member

    Better late then never ;)
     
  19. MsJacquiiC

    MsJacquiiC Well-Known Member

    Nice share = Thanks :)

    J.
     
  20. Joël

    Joël Member

    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...?
     

Share This Page