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™

Hide specific content on specific pages

s2Member Plugin. A Membership plugin for WordPress®.

Hide specific content on specific pages

Postby hazardous_waster » July 9th, 2011, 6:03 am

Hello All!

Right I've had a look round the forums and can't find how to do this one. What my client wants to do is when a user is loged on to the site they'll see an extra chunk of content with extra content in at the bottom of the pages, so what I'd like is some sort of tag I can put on a div (don't mind if its ard coded in to the page template) or something I can wrap around said chunk of content so that'll only display to people who are loged in ... I had a look at the tags thing in s2member but that goes about about specific posts or pages ... not taging content on pages.

make sense? possible?

Thanks in advance,
Neil Kelsey
User avatar
hazardous_waster
Registered User
Registered User
 
Posts: 12
Joined: May 19, 2011

Re: Hide specific content on specific pages

Postby cassel » July 9th, 2011, 7:09 am

For having done it myself, you can use the conditionals to insert content. Something like this:

Content for everyone to see.
[s2If is_user_logged_in()]
Content for anyone that is logged in, regardless of their Membership Level.
[/s2If]


So whatever is wrapped in the conditional will only be displayed to logged in members. The others will not even see there is something there. And of course, the conditionals like that can take many forms and get more complex. Just as an example:
http://scrapbookcampus.com/basic-tutori ... tshop-pro/

In that page, some content is viewable by ALL, but if you are logged in, some content will appear, other will disappear, and if you are a paying member, still different content will display. It is fun to play with!
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Hide specific content on specific pages

Postby hazardous_waster » July 9th, 2011, 7:13 am

perfect!! Just tried it works a treat, thank you!
User avatar
hazardous_waster
Registered User
Registered User
 
Posts: 12
Joined: May 19, 2011

Re: Hide specific content on specific pages

Postby hazardous_waster » July 11th, 2011, 1:13 pm

Ok one further point .. I really need to do a similar thing to this but on a template, they want a different link box to appear if the user is loged in or not so I gotta use some HTML, but the editor seems to strip any html out I put in (pain in the ***) ... is that possible too?

N
User avatar
hazardous_waster
Registered User
Registered User
 
Posts: 12
Joined: May 19, 2011

Re: Hide specific content on specific pages

Postby cassel » July 11th, 2011, 1:23 pm

Are you typing the codes in the Visual or the HTML format? Which editor are you using?
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Hide specific content on specific pages

Postby hazardous_waster » July 11th, 2011, 1:42 pm

I've got these sorts of codes working just fine in the Wordpress page wysiwyg editor

[s2If is_user_logged_in()]
Content for anyone that is logged in, regardless of their Membership Level.
[/s2If]

But what I'm asking is can I on a page template, say I make a new one called 'switching-content.php' is there something I can write to do a similar thing for example

<? if (user is loged in)
{
<div> display this lovely div! </div>
} else
{
<div> they'll see this horrible one! </div>
} ?>

Yeah as you can see I'm no php coder, but I hope that explains what I'm after
User avatar
hazardous_waster
Registered User
Registered User
 
Posts: 12
Joined: May 19, 2011

Re: Hide specific content on specific pages

Postby PseudoNyhm » July 11th, 2011, 1:45 pm

I had similar editor issues with WordPress, especially when trying to insert HTML, PHP, JavaScript, or even just shortcodes. The trouble is that even if you use the so-called HTML editor, or turn off the Visual editor in the admin user preferences, the WordPress HTML editor still inserts line breaks, paragraph tags, and performs other formatting, which breaks code.

I recently installed TRUEedit, which allows you to switch off the WordPress formatting. This makes the HTML editor a true source editor (what you type will be what ends up as the page source).
User avatar
PseudoNyhm
Experienced User
Experienced User
 
Posts: 79
Joined: June 19, 2011

Re: Hide specific content on specific pages

Postby cassel » July 11th, 2011, 1:50 pm

I am not coder either but if you look under API / Scripting > Advanced Conditionals, you might find other codes to enter. I am not 100% it will work but worth a try until someone more knowledgeable chimes in.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Hide specific content on specific pages

Postby Cristián Lávaque » July 11th, 2011, 8:54 pm

PseudoNyhm wrote:I recently installed TRUEedit, which allows you to switch off the WordPress formatting. This makes the HTML editor a true source editor (what you type will be what ends up as the page source).


Brilliant tip! Thanks! :D

cassel wrote:I am not coder either but if you look under API / Scripting > Advanced Conditionals, you might find other codes to enter. I am not 100% it will work but worth a try until someone more knowledgeable chimes in.


Correct. :)
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: Hide specific content on specific pages

Postby hazardous_waster » July 18th, 2011, 2:01 pm

Still having troubles with this trying to find a solution .. seems like it should be such a simple thing to do I thought I'd give it another shot, anyone else had any joy trying to do something similar?
User avatar
hazardous_waster
Registered User
Registered User
 
Posts: 12
Joined: May 19, 2011

Re: Hide specific content on specific pages

Postby Cristián Lávaque » July 19th, 2011, 10:33 pm

Take a look at the documentation here WP Admin -> s2Member -> API / Scripting -> Advanced/PHP Conditionals -> Example #1.

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 } ?>


I hope that helps.
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


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest

cron