Insert body class on login page

Discussion in 'Integration' started by bennyuk1, Feb 22, 2017.

  1. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    159
    am v5.1.7
    wp v4.6

    I have some shortcodes that just dont seem to be working properly on login page (seems not to be loading all js_composer scripts)

    Is there a way I can set a class on the body tag so that I can hide the errors using css. I need a way of selecting just the items on the login page.
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,660
    Hello,

    Do you want to avoid editing of templates?

    You can use the following code in file site.php in this case:
    http://www.amember.com/docs/Site.php_file
    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, function(Am_Event_AfterRender $e) {
        if (
    strpos($e->getTemplateName(), 'login.phtml')!==false) {
            
    $e->replace('/<body/''<body class="login-page" ');
        }
    });
    This code add class login-page to body tag. In case of your layout already have class attribute on body then you need to modify my code in order to add additional class to existing attribute instead of add additional one.

    Best Regards.
  3. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    159
    That's great! many thanks. I'll give it a go. Can you let me know, the option for editing the templates as well please?
  4. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    159
    It worked! Perfectctly, many thanks.

    Changed to
    $e->replace('/<body class="/', '<body class="login-page ');
    to add to exisitng classes on body
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,660
    It is great.

    File with template can be found here:
    application/default/views/admin/login.phtml

    By the way login page already have unique CSS
    class and you can use it in your CSS cascade - form-login-wrapper

    Reference:
    http://www.amember.com/docs/Themes_and_Templates
    bennyuk1 likes this.

Share This Page