• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 How pre-check "stay logged in" in logged in template?

Marcus

Well-known member
#1
How can I pre-check "stay logged in" in the logged in template? It is the checked="checked" html statement.

If not done by css, how would you do that with javascript: with jquery once the user clicks on "register or login" is the best guess, agreed?
 

Marcus

Well-known member
#3
Yes this is exactly how I have it now. I want a solution that does not change the template. As there is no template hook I could add a javascript to the bottom of all my pages for not logged in users that activates the checked attribute once a user clicks on the "register or login" link. Or it just adds the checked attribute everytime. I don't know if this can be a performance issue.
 

Fuhrmann

Well-known member
#4
Yes this is exactly how I have it now. I want a solution that does not change the template. As there is no template hook I could add a javascript to the bottom of all my pages for not logged in users that activates the checked attribute once a user clicks on the "register or login" link. Or it just adds the checked attribute everytime. I don't know if this can be a performance issue.
I make it work here, but i dont know, as you said, if this can be a performance issue. But that's it:

PHP:
<?php

class LoginChecked_Listener
{
    public static function template_post_render ($templateName, &$content, array &$containerData, XenForo_Template_Abstract $template)
    {
        if ($templateName == 'PAGE_CONTAINER')
        {
            $content = str_replace('<input type="checkbox" name="remember"', '<input type="checkbox" name="remember" checked="checked" ', $content);
        }
    }
}

?>
Maybe there is another easy way to do it. But works, anyway.
 

Marcus

Well-known member
#5
I did only see your post now. I have created a javascript that adds the checked attribute to this input field once you click on "register or sign in" in a custom template added after template hook body. All other template hooks in PAGE_CONTAINER are above this field.

It is interesting to know what is the faster approach.
 

Fuhrmann

Well-known member
#6
I did only see your post now. I have created a javascript that adds the checked attribute to this input field in a custom template executed below template hook body.

It is interesting to know what is the faster approach.
That's nice. Would like to know this too.