PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Conditional widgets?

s2Member Plugin. A Membership plugin for WordPress®.

Conditional widgets?

Postby cassel » July 22nd, 2011, 9:31 pm

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"?
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional widgets?

Postby Cristián Lávaque » July 23rd, 2011, 12:15 am

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.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Conditional widgets?

Postby wouthe » September 11th, 2011, 6:25 pm

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.
User avatar
wouthe
Registered User
Registered User
 
Posts: 11
Joined: September 11, 2011

Re: Conditional widgets?

Postby cassel » September 12th, 2011, 10:31 am

I gave up on the conditional widget. It might be possible but above my knowledge.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional widgets?

Postby wouthe » September 12th, 2011, 1:03 pm

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.
User avatar
wouthe
Registered User
Registered User
 
Posts: 11
Joined: September 11, 2011

Re: Conditional widgets?

Postby wouthe » September 12th, 2011, 6:18 pm

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.
User avatar
wouthe
Registered User
Registered User
 
Posts: 11
Joined: September 11, 2011

Re: Conditional widgets?

Postby wouthe » September 12th, 2011, 7:19 pm

The above works perfect :D these conditionals are pretty powerful!

Regards
User avatar
wouthe
Registered User
Registered User
 
Posts: 11
Joined: September 11, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 2 guests

cron