Community Support Forums — WordPress® ( Users Helping Users ) — 2010-10-25T23:17:19-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=1074 2010-10-25T23:17:19-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1074&p=4207#p4207 <![CDATA[Re: Code "If" or "Switch?"]]> Awesome. Thanks for reporting back on this.
~ Much appreciated.

Statistics: Posted by Jason Caldwell — October 25th, 2010, 11:17 pm


]]>
2010-10-25T18:28:07-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1074&p=4188#p4188 <![CDATA[Re: Code "If" or "Switch?"]]>
Thanks anyway.

I'm leaving the message intact, because I put it here and didn't want to delete what was up.

***************************************

Jason,

I copied your code from above and wrapped my "home" page in the public content. Then I logged out and went ot my home page. The content was not displayed. Did I miss something?

What I used ...
Code:
    <?php if (current_user_is("s2member_level4")){ ?>
        Some premium content for Level 4 Members.
    <?php } else if (current_user_is("s2member_level3")){ ?>
        Some premium content for Level 3 Members.
    <?php } else if (current_user_is("s2member_level2")){ ?>
        Some premium content for Level 2 Members.
    <?php } else if (current_user_is("s2member_level1")){ ?>
        Some premium content for Level 1 Members.
    <?php } else if (current_user_is("s2member_level0")){ ?>
        Some content for Free Subscribers.
    <?php } else { ?>
        Content from my home page went here.
    <?php } ?>

Statistics: Posted by KirkWard — October 25th, 2010, 6:28 pm


]]>
2010-10-25T12:11:45-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1074&p=4174#p4174 <![CDATA[Re: Code "If" or "Switch?"]]>
Expanding on your suggested usage above, and what I saw in the video about using advanced conditionals, would this work to allow me to show specific content, such as buttons on the member options page?

Code:
    <?php if (is_user_logged_in && current_user_can ("s2member_level4")){ ?>
        Some premium content for Level 4 Members, but not for members of any other level.

    <?php } else if (is_user_logged_in && current_user_can ("s2member_level3")){ ?>
        Some premium content for Level 3 Members, but not for members of any other level.

    <?php } else if (is_user_logged_in && current_user_can ("s2member_level2")){ ?>
        Some premium content for Level 2 Members, but not for members of any other level.

    <?php } else if (is_user_logged_in && current_user_can ("s2member_level1")){ ?>
        Some premium content for Level 1 Members, but not for members of any other level.

    <?php } else if (is_user_logged_in && current_user_can ("s2member_level0")){ ?>
        Some content for Free Subscribers, but not for members of any other level.

    <?php } else { ?>
        Some public content, not for members of any other level.
    <?php } ?>

Statistics: Posted by KirkWard — October 25th, 2010, 12:11 pm


]]>
2010-10-25T10:10:35-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1074&p=4168#p4168 <![CDATA[Re: Code "If" or "Switch?"]]>
Don't like strings of "if" statements as it's too easy for old brains to get confused. We have enough trouble remembering how to turn our computers on.

Statistics: Posted by KirkWard — October 25th, 2010, 10:10 am


]]>
2010-10-25T02:54:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1074&p=4164#p4164 <![CDATA[Re: Code "If" or "Switch?"]]> Hi Kirk. Thanks for the excellent question.

Please try it like this instead:
Code:
<?php if (current_user_is("s2member_level4")){ ?>
    Some premium content for Level 4 Members.
<?php } else if (current_user_is("s2member_level3")){ ?>
    Some premium content for Level 3 Members.
<?php } else if (current_user_is("s2member_level2")){ ?>
    Some premium content for Level 2 Members.
<?php } else if (current_user_is("s2member_level1")){ ?>
    Some premium content for Level 1 Members.
<?php } else if (current_user_is("s2member_level0")){ ?>
    Some content for Free Subscribers.
<?php } else { ?>
    Some public content.
<?php } ?>
Documented in your Dashboard under: s2Member -> API Scripting -> Advanced Conditionals.

Or, if you really like the switch() function, do it this way:
Code:
<?php
switch 
(ws_plugin__s2member_user_access_level ())
    {
        case 4:
            echo 'Some premium content for Level 4 Members.';
            break;
        case 3:
            echo 'Some premium content for Level 3 Members.';
            break;
        case 2:
            echo 'Some premium content for Level 2 Members.';
            break;
        case 1:
            echo 'Some premium content for Level 1 Members.';
            break;
        case 0:
            echo 'Some content for Free Subscribers.';
            break;
        default:
            echo 'Some public content';
    }
?>


If you'd like to do this without using PHP, here is a Shortcode equivalent:
Code:
[s2If current_user_is(s2member_level4)]
   Some premium content for Level 4 Members.
[/s2If]

[s2If current_user_is(s2member_level3)]
   Some premium content for Level 3 Members.
[/s2If]

[s2If current_user_is(s2member_level2)]
   Some premium content for Level 2 Members.
[/s2If]

[s2If current_user_is(s2member_level1)]
   Some premium content for Level 1 Members.
[/s2If]

[s2If current_user_is(s2member_level0)]
   Some content for Free Subscribers.
[/s2If]

[s2If !current_user_can(access_s2member_level0)]
   Some public content.
[/s2If]
Perfect for the WordPress® Visual Editor.
Documented in your Dashboard, under: s2Member -> API Scripting -> Simple Conditionals

Statistics: Posted by Jason Caldwell — October 25th, 2010, 2:54 am


]]>
2010-10-24T21:55:20-05:00 http://www.primothemes.com/forums/viewtopic.php?t=1074&p=4160#p4160 <![CDATA[Code "If" or "Switch?"]]>
Code:
<?php
switch (current_user_is($i) {
    case s2member_level4:
      Some premium content for Level 4 Members.
      break;
    case s2member_level3:
      Some premium content for Level 3 Members.
      break;
    case s2member_level2:
      Some premium content for Level 2 Members.
      break;
    case s2member_level1:
      Some premium content for Level 1 Members.
      break;
    case s2member_level0:
      Some content for Free Subscribers.
      break;
    default:
      Some public content.;
} ?>

Statistics: Posted by KirkWard — October 24th, 2010, 9:55 pm


]]>