• Resolved Yolle

    (@yolle)


    Would it be possible with s2member to show links to pages according to ccaps?
    So that an s2member level 1 with ccap XXX would see a link to a page (in the sidebar for example) to with ccap XXX, and an s2member with ccap YYY to a page with ccap YYY, but the links would not show for the user who does not have the right ccap?

    Or, to put in maybe in a better way, that s2members would only see links to pages that they can open with their ccap.

    Thanks!

    https://www.ads-software.com/plugins/s2member/

Viewing 5 replies - 1 through 5 (of 5 total)
  • That is possible, but not because of the links themselves.

    Instead, you’d just put in the links inside the relevant shortcode. See s2Member -> API/Scripting -> Custom Capabilities

    Thread Starter Yolle

    (@yolle)

    Great, thanks! I’ll have a look.

    Thread Starter Yolle

    (@yolle)

    Hi again!

    I kind of got it to work using this code

    [s2If current_user_can(access_s2member_level1)]
    
        Some premium content for all Level 1 Members.
    
        [_s2If current_user_can(access_s2member_ccap_music)]
            Display links for music as well.
        [/_s2If]
    
        [_s2If current_user_can(access_s2member_ccap_videos)]
            Display videos as well.
        [/_s2If]
        [_s2If current_user_can(access_s2member_ccap_xxx)]
            Display xxx as well.
        [/_s2If]
        [_s2If current_user_can(access_s2member_ccap_yyy)]
            Display yyy as well.
        [/_s2If]
    
    [/s2If]

    The problem is, that I end up with many blank lines, when the s2member doesn’t have the specific ccap… Is there a way not to show blank lines?
    Thank you very much!

    First, if the post or page is already protected at level 1, you don’t need the very first shortcode (and therefore not the last either).

    Getting rid of the blank lines depends on how your site is set up — I think it’s something to do with WordPress’s autop function –but is usually just a matter of deleting the blank lines in your code, or of putting shortcodes and text on the same line, like this:

    [_s2If current_user_can(access_s2member_ccap_music)]Display links for music as well.[/_s2If]
    [_s2If current_user_can(access_s2member_ccap_videos)] ...

    You might need to play around with it a little bit, but then you’ll see what works for your site.

    Thread Starter Yolle

    (@yolle)

    Hi!

    I managed to solve it with by putting all the code into one line and then adding <p> before every [/_s2If]

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show links to pages according to ccaps’ is closed to new replies.