latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

php code string to get user level

Home Forums Community Forum php code string to get user level

This topic contains 6 replies, has 2 voices. Last updated by  Eduan 4 years, 3 months ago.

Topic Author Topic
Posted: Thursday Oct 4th, 2012 at 5:19 pm #27476
Jon Henwood
Username: jon73

Hi

The S2members is a great plugin and the guidance on each step was invaluable to me today. Really appreciate the work you have put into this.

Can some one help me locate the php code string that will show the user level. We want to have a “Go Plus” button on the site but only show it when the free member is logged on and dont show it once they have become a paid member.

Thanks again

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Thursday Oct 4th, 2012 at 5:44 pm #27480
Eduan
Username: Eduan
Moderator

Hello Jon,

So basically do you want to show a different content (or none at all) depending if the user is logged in or not, correct?

In that case, you might be interested in using s2Member conditionals: Knowledge Base » s2Member® Conditionals

Hope this helps. :)

Posted: Thursday Oct 4th, 2012 at 5:54 pm #27485
Jon Henwood
Username: jon73

Hi

Thanks for getting back to me. Its more for wrapping around a button that sits next to the persons avatar. This button will:

– Not show if user is not logged in
– Show if user is logged in as a standard registration
– Not show if the user is a paid member

But the conditionals certainly help with another issue I was wondering about…. I think. Will give them a try and get back to you.

Thanks for the help

Posted: Thursday Oct 4th, 2012 at 6:12 pm #27494
Jon Henwood
Username: jon73

Hi

The conditions work well for the two different bits of content I want to use but what would I use for the no logged in users cause I want them to see on bit of content (if they are not registered) and logged in users (registered but not paid) to see a different piece of content….

[s2If current_user_is(s2member_level0)]
Content shown to non logged in people viewing the site
[/s2If]
[s2If current_user_is(s2member_level1)]
Upgrade from normal registration content here
[/s2If]

Currently the content I have showing for level 1 is showing for lvel 0. Which is right but what do I replace level 0 with for non logged on site visitors.

Thanks

Posted: Thursday Oct 4th, 2012 at 6:56 pm #27501
Eduan
Username: Eduan
Moderator

Well, if you want to check whether the user is logged in or not you would use:

[s2If !is_user_logged_in()]
    Some public content. They're NOT logged in.
        A leading !exclamation means false.
[/s2If]

The PHP version would be:

<?php if(is_user_logged_in()){ ?>
    Content for anyone that is logged in, regardless of their Membership Level.
<?php } else { ?>
    Some public content.
<?php } ?>

Hope this helps. :)

Posted: Thursday Oct 4th, 2012 at 6:59 pm #27503
Jon Henwood
Username: jon73

Eduan…you’re a star!

Posted: Thursday Oct 4th, 2012 at 8:28 pm #27514
Eduan
Username: Eduan
Moderator

Glad I was able to help. :)

Viewing 6 replies - 1 through 6 (of 6 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.