Page 1 of 1
Conditional widgets?

Posted:
July 22nd, 2011, 9:31 pm
by cassel
I am trying to use a couple of widgets that i would like accessible only to some members. Is it possible to use conditionals on widgets? Like, if a member is not logged in, this widget will not display, but if member is logged in, then the widget will display?
As another question, are conditionals only useable with member levels and ccaps, or can i use other WP roles, like "admin"?
Re: Conditional widgets?

Posted:
July 23rd, 2011, 12:15 am
by Cristián Lávaque
I believe you can use those conditionals with other roles too. For admins you have is_admin(), if I remember correctly.
I don't know how to make a widget conditional from the dashboard, but you may try editing the widget using a hook to add the conditions.
Re: Conditional widgets?

Posted:
September 11th, 2011, 6:25 pm
by wouthe
Hi Cassel,
I want to do the same thing. Did it work to make your widget conditional?
I want to do it with a 'recent comments' widget. This means that non-members should not be able to see what is said inside, but the widget has to be present in the footer bar.
Thanks.
Re: Conditional widgets?

Posted:
September 12th, 2011, 10:31 am
by cassel
I gave up on the conditional widget. It might be possible but above my knowledge.
Re: Conditional widgets?

Posted:
September 12th, 2011, 1:03 pm
by wouthe
OK thanks.
The easiest way is to use the s2cleantheme. It comes with a footer only visible when logged in.
As I want to start of from a different theme frame, I'll try to implement this feature into my theme. I'm afraid this will not be easy though.
Did anyone try this before?
Thanks.
Re: Conditional widgets?

Posted:
September 12th, 2011, 6:18 pm
by wouthe
I think I can also play around with combining the PHP conditionals with the footer.
By using
- Code: Select all
<?php if(is_user_logged_in()){ ?>
Content for anyone that is logged in, regardless of their Membership Level.
<?php } else { ?>
Some public content.
<?php } ?>
in the footer, it might be possible to hide the footer for the public.
Let's try this.
Re: Conditional widgets?

Posted:
September 12th, 2011, 7:19 pm
by wouthe
The above works perfect

these conditionals are pretty powerful!
Regards