so I'm running a membership site and want the login page to promote the value of signing up. I can't figure out how to get a sidebar to display on this page. Everything I've tried breaks wp-login.php. Any ideas?

  • there are few to no hooks on wp-login.php, which does not make this easy, but it can be done... sounds more like you could use the theme my login plugin then you can adjust the login page content way more easily. – majick Jul 28 '16 at 13:07
  • Thanks @majick - I was under the impression that theme my login was all css based, am I wrong? – JimO Jul 28 '16 at 13:26
  • no it does more than that... for example if logged out it will redirect /wp-admin/ to a custom login page /login/, though normal wp-login.php will still be available (which is nice to have as a fallback)... but the main thing is you can style or edit the login page content (and other related pages) as a normal page to whatever you like and call the login form with a shortcode. it also allows you to have custom templates for that form and/or others. plus some other optional modules. – majick Jul 28 '16 at 13:34
  • Thanks mate, I'll give that a whirl. Sounds like a much easier way of accomplishing it! – JimO Jul 28 '16 at 13:55
  • yeah it sure is, I've added my hack to do it the other way, as you can see it is not so easy but can be done. – majick Jul 28 '16 at 14:17

Here is my hack to add content above the login form using the login_body_class filter...

function login_body_hack($classes) {
    $classes[] = 'PLACEHOLDER';
    add_filter('attribute_escape', 'login_body_filter_hack',999,2);
    return $classes;

function login_body_filter_hack($safe_text, $text) {

    // add whatever you like content here
    $newcontent = '<div id="contentwrapper'>CONTENT</div>';

    $replace = '">'; // closes the body tag early
    $replace .= $newcontent;
    // some tag to be closed, as suffixed with the original ">
    $replace .= '<img src="javascript:void(0);" style="display:none;'; 
    $safe_text = str_replace('PLACEHOLDER',$replace,$safe_text);
    remove_filter('attribute_escape', 'login_body_filter_hack',999,2);
    return $safe_text;

Note however that "as is" this will the content to all "login" pages (register, reset, lost password etc.) not just the login form one, so further checks would be needed to handle those cases.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.