Support

Home Forums Event Espresso Premium Hiding right sidebar if user is logged in

Hiding right sidebar if user is logged in

Posted: April 26, 2017 at 1:49 pm

Viewing 1 reply thread


rhj4

April 26, 2017 at 1:49 pm

I am using the right sidebar to convey information of interest to non-logged-in visitors to my site. If a user is logged in, I want to reclaim that space. I have this code in my Iced Mocha Miscellaneous settings:

jQuery(document).ready(function($) {
 jQuery('.breadcrumbs').hide(); 
 if (is_user_logged_in()){
	jQuery('#secondary').hide();
	jQuery('#content').css('width','100%');
  }
}); 

If I manually run the last two lines in the browser diagnostic window, the right column gets hidden and the content area expanded. However, if I just load the page (when logged in), I get this message:
You currently have no widgets set in the right sidebar. You can add widgets via the Dasboard.
To hide this sidebar, switch to a different Layout via the Theme Settings.

I cannot find where in the Theme Settings I go to hide this sidebar… if logged in.


Josh

  • Support Staff

April 26, 2017 at 2:19 pm

Hi Bob,

You won’t find settings for hiding/showing things based on whether someone is logged in, because settings like those don’t exist.

Here’s some code you can use instead:

jQuery(document).ready(function($) {
 $('.breadcrumbs').hide(); 
 if ($('body').hasClass('logged-in')){
	$('#secondary').hide();
	$('#content').css('width','100%');
  }
});

The reason the code that you tried didn’t work is because PHP functions (which was this one) will generally not work when they’re included directly within JavaScript code.

Viewing 1 reply thread

The support post ‘Hiding right sidebar if user is logged in’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso