Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Sidebars & Widgets »

[SOLVED] Hide the right sidebar for subscribers


  #1  
Old May 3, 2011, 09:39 PM
dcclxi
 
10 posts · May 2011
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
  #2  
Old May 3, 2011, 11:30 PM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
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() ) { ?>
.colthree, td#right {
    display: none;
}
<?php } ?>
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #3  
Old May 4, 2011, 09:52 PM
dcclxi
 
10 posts · May 2011
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 -----*/
	
table#layout {
	font-size: 100%;
	width: 100%;
	table-layout: fixed;
	}

.colone {width: <?php echo $bfa_ata['left_sidebar_width']; ?>px;}
.colone-inner {width: <?php echo $bfa_ata['left_sidebar2_width']; ?>px;}
.coltwo { width: 100% }
.colthree-inner {width: <?php echo $bfa_ata['right_sidebar2_width']; ?>px;}
.colthree {width: <?php echo $bfa_ata['right_sidebar_width']; ?>px;}

/* code change, start */
<?php if ( !current_user_can('delete_posts') ) { ?>
	.colone, .colthree {
		...
	}
<?php } ?>
/* code change, end */
The php line ensures this code change only applies to subscribers (see table at http://codex.wordpress.org/Roles_and_Capabilities).
The "..." bit can be:
HTML Code:
display: none;
which leads to a weird behaviour. Or:
HTML Code:
width: 0px;
which does shrink both sidebars to 0px, allows the central area to spread wider, but the sidebar content logically overflows (hence not hidden).

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?
  #4  
Old May 4, 2011, 09:57 PM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
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.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #5  
Old May 4, 2011, 10:27 PM
dcclxi
 
10 posts · May 2011
I don't like editing the theme either, I wish I could find another way to hide these sidebars. I'll keep searching :-).
  #6  
Old May 4, 2011, 10:39 PM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
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() ) { ?>
.colthree, td#right, .colone, td#left {
    display: none;
}
<?php } ?>
I just put that in my test site and when logged in see no sidebars. It would seem all you have to do if figure out how to determine the code for what type of use is logged in.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #7  
Old May 5, 2011, 10:17 AM
dcclxi
 
10 posts · May 2011
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?
  #8  
Old May 5, 2011, 12:07 PM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
In ATO>Add HTML/CSS Inserts>CSS Inserts
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #9  
Old May 5, 2011, 09:55 PM
dcclxi
 
10 posts · May 2011
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') ) { ?>
.colthree, td#right, .colone, td#left {
    display: none;
}
<?php } ?>
I am really stupid for not finding the CSS insert place in the theme interface (!). My excuse is that I am sleep depraved because feeding at day and night a 2-month old little boy :-).

Thanks a lot for your help!

Bookmarks

Tags
sidebar, sidebar coding, users

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Feedburner shows 0 subscribers, Google reader shows 91 subscribers? Patty RSS, Feeds & Subscribing 0 Feb 24, 2011 09:29 PM
Not showing subscribers ProtinaseMegan RSS, Feeds & Subscribing 1 Jun 2, 2010 06:27 PM
Hide a Post but have a Link to it in Sidebar treeplant Center area post/pages 6 Apr 18, 2010 08:22 PM
[SOLVED] How to hide or make invisible Text-Widget in sidebar multiram Sidebars & Widgets 4 Jul 23, 2009 09:02 AM
Hide subcategories in right sidebar Radical Sidebars & Widgets 0 May 15, 2009 06:12 AM


All times are GMT -6. The time now is 06:10 PM.


Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.