[SOLVED] Hide the right sidebar for subscribers
Hello,
First thank so much for this theme, I have spent months looking for something flexible enough but still easy to use and Atahualpa is simply perfect! My question is about the sidebars. I would like to know how I can hide the right sidebar if the user is "only" a subscriber. The website I have set up is only accessible to registered users. They are divided into two classes: those who are subscribers and those are not. The subscribers have a restricted view of the content (they only see posts from one category only). That restriction unfortunately does not spread to all widgets, so I would like to hide the right sidebar (to hide its widgets). I took a look at the theme code via the WP Editor, but I can't work out where the Atahualpa code creates the HTML/CSS for the sidebars. I thought that perhaps I could add a if (!current_user_can('delete_posts') ) { ... } // user is a subscriber somewhere, but I don't find the right place. I would prefer not to have to do any code change, but so far it is the only solution that is likely to work. I would really appreciate any help on this... dcclxi |
I did a little digging and the following will hide the right sidebar if a user is logged in. Not sure how you would limit to subscriber etc. but maybe it's a start. I put this in CSS Inserts.
HTML Code:
<?php if ( is_user_logged_in() ) { ?> |
Thank you so much for such a quick answer!
I tried it, it half works: the sidebars (I went for hiding both the left and right one) are hidden, but the central area then shrinks to the width of the (disappeared) left sidebar (or at least looks like it). I can't work out why. I kept playing a bit with the code and eventually got to this (in css.php) : HTML Code:
/*-------------------- LAYOUT to keep it all together -----*/ The "..." bit can be: HTML Code:
display: none; HTML Code:
width: 0px; If you have any idea... There must be a place in all the php files of the theme where the user's choice regarding whether to display or not a sidebar (left, left inner, right inner, right) is retrieved. Perhaps that is where the code change should be done? |
I avoid editing theme files except for bug fixes and the like as they won't survive an upgrade and I don't want to have to document all the changes I made to a particular installation so I can "redo" the hacks. That's why I stick primarily with code in the theme options and is why I like this theme so much in that you can do most anything you want within the theme options if you think through it.
|
I don't like editing the theme either, I wish I could find another way to hide these sidebars. I'll keep searching :-).
|
Was the code you put in CSS Inserts something like the following without any of the other code you tried?
HTML Code:
<?php if ( is_user_logged_in() ) { ?> |
I tried this but there was an issue so perhaps I didn't put it in the right place. Where did you add this CSS code?
|
In ATO>Add HTML/CSS Inserts>CSS Inserts
|
It works!! Brilliant!!!
I got the code to work only for subscribers by changing the php if condition: HTML Code:
<?php if ( !current_user_can('delete_posts') ) { ?> Thanks a lot for your help! |
All times are GMT -6. The time now is 09:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.