ThemeShaper Forums » Thematic

Add Body Class for WP User Login Error?

(5 posts)
  • Started 10 years ago by awarner20
  • Latest reply from awarner20
  • This topic is not resolved
  1. Hi all,

    Ok, this is a wild probably, but hopefully someone can shed some light on what my next move should be. I have been tracking a solution for awhile and I think I'm getting closer to knowing what I need, but I'm not sure it's possible to achieve.

    In short - I have some code now checking for a body class of "loggedin". I need this code to also check for a body class of "loginerror". I think Thematic is assigning the "loggedin" body class as I see this line in the dynamic-class.php file.

    // For when a visitor is logged in while browsing
    	if ( $current_user->ID )
    		$c[] = 'loggedin';

    Is there a way to add a body class for "loginerror"? I am making an assumption that if I can create that body class, I can filter the body class function to add it, and then add a check for that into the code I referenced in the beginning.

    Curious about what I'm trying to do? Read more here:

    You'll see my path as I was troubleshooting this solution...which led me to Thematic assigning the body classes :)

    Any advice would be greatly appreciated...

    Posted 10 years ago #
  2. This is pretty cool. I gave it a walkthrough. Try:

    function e_body_class($classes) {
    	global $myerrors; // Sidebar Login's WP_Error variable 
    	if ( is_wp_error($myerrors) ) {
    		$classes[] = "login-error";
    	return $classes;
    Posted 10 years ago #
  3. @ em hr,

    That is cool, and works a charm adding that to the body class! I added that function to my child theme's functions.php file. Viewing the source shows that the class has been added...
    <body class="wordpress y2010...<content shortened>....login-error">

    I then went into the plugin's edited panel.js file and added (what I think) is the correct code:

    I changed this:
    if ($j('body').is('.loggedin')) {
    to this:
    if ($j('body').is('.loggedin') || ($j('body').is('.login-error')) {

    ...but so far, no luck.

    Posted 10 years ago #
  4. don't you mean to use:
    if ( $j('body').is('.loggedin') || $j('body').is('.login-error') )

    Posted 10 years ago #
  5. Sorry it's been so ling since this reply...

    @em hr,

    I appreciate your correction here, my lack of syntax knowledge is easily seen;)

    Unfortunately this doesn't seem to be working either. My full code is below and the .login-error body class IS being added.

    /* Cookie Handling */
          // Check if loggedin or login-error body class (login-error body class added
          // by function from em hr on Thematic forums)
              if ( $j('body').is('.loggedin') || $j('body').is('.login-error') ) {
                 // Logged in - set cookie if not set already, and display panel
                    var show_panel = $j.cookie('show_panel');
                    if (show_panel=='no') {} else {
                        $j ( '#sliding-panel .panel' ).show();
                        $j ( '#sliding-panel .tab' ).addClass( 'current' );
                        $j ( '#sliding-panel .toggle' ).hide();
                        $j ( '#sliding-panel .toggle a.close' ).show();
                        $j.cookie('show_panel', 'no', { domain: '' });
                } else {
                    // Not logged in
                    $j.cookie('show_panel', null, { domain: '' });
            /* End Cookie Handling */

    The expected functionality of the panel staying open on successful login is there, but it still doesn't stay open upon login-error (even though this body class exists).

    I wonder if you have any further thoughts on why this logic isn't working?

    Posted 10 years ago #

RSS feed for this topic


You must log in to post.