How to use s2IF / else properly and a way to substitute user level in a url

Forums General How to use s2IF / else properly and a way to substitute user level in a url

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #518
    Joshua Shapiro
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4777

    Hi Cristian

    I have almost working properly what I call my member page for our free 30 day trial members (level 1)
    however I have to make all these files also available to our paid members

    so at the bottom of this page is a link to return to the Member Welcome page —
    but I have to check which level they are to know which welcome page to go back to

    I have figured out how to do this with a /s2IF –> s2IF/ as follows:

    [s2If current_user_is(access_s2member_level1)]
    Home Page: [ <span style=”color: #ff0000;”>click here</span> ]
    Logout of Membership: [ <span style=”color: red;”>[logout_to_home text=”click here”]</span> ]
    [/s2If]
    [s2If current_user_is(access_s2member_level2)]
    Home Page: [ <span style=”color: #ff0000;”>click here</span> ]
    Logout of Membership: [ <span style=”color: red;”>[logout_to_home text=”click here”]</span> ]
    [/s2If]
    [s2If current_user_is(access_s2member_level3)]
    Home Page: [ <span style=”color: #ff0000;”>click here</span> ]
    Logout of Membership: [ <span style=”color: red;”>[logout_to_home text=”click here”]</span> ]
    [/s2If]
    [s2If current_user_can(access_s2member_level4)]
    Home Page: [ <span style=”color: #ff0000;”>click here</span> ]
    Logout of Membership: [ <span style=”color: red;”>[logout_to_home text=”click here”]</span> ]
    [/s2If]

    however when I display the page for each s2IF test that is false there is a blank line
    displaying on the page

    now since I used the strategy to do the “level”-account-page strategy is there a way I can avoid
    all the /s2IF conditions by replacing the level number in a symbolic way like we do within s2member
    using %%current_user_level%% which if I replace the level number as
    %%current_user_level%%-account-page it doesn’t work?

    second is this how /s2if works if the condition is false it shows as a blank line on the screen?
    if I use /s2IF with else – will this eliminate the blank line?

    with the logic above since I am the admin I will fall into level4 – so there is like 4 blank lines
    before I have the option to go to my Member Home Page or Logout

    thank you – Joshua

    #519

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4777

    however when I display the page for each s2IF test that is false there is a blank line
    displaying on the page

    Try not having a line-break between the closing and opening s2If tags.

    is there a way I can avoid all the /s2IF conditions by replacing the level number

    You could do that with s2Get and the level number, if your URLs only change by the level number.

    If you have URLs that are more different than just the level number, then you’d need a bit of PHP instead of shortcodes (maybe an array with the level number as the key and the URL as the value).

    since I am the admin I will fall into level4

    You have Level 4 access, but you don’t have the Level 4 role, you are an Administrator.

    current_user_is(access_s2member_level1)

    access_s2member_level1 is a capability, which you check with current_user_can. current_user_is checks the role, so it’d be s2member_level1.

    current_user_is(s2member_level1)

    current_user_can(access_s2member_level1)

    See also:
    https://codex.wordpress.org/Glossary#Role
    https://codex.wordpress.org/Glossary#Capabilities

    #520
    Joshua Shapiro
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4777

    Cristian

    I have the welcome pages setup as 1-account-page, 2-account-page, etc …

    I tried in my url to use:

    [s2Get user_field="s2member_access_level" /]-account-page
    but of course this url wasn’t recognized – is there a way
    to use some variable for the level that instead of using
    s2IF statement it will convert the level # to get me to the right
    welcome/member page?

    back to Level access versus role —

    so you are say if a person is level 1 – as an example
    access_s2member_level1 – is a capability – but if there
    are no capabilities for level1 and a person is level 1 is it true?

    my level2 has two capabilities novel1 and novel2
    so it would be current_user_can(access_s2member_level2_novel1)? then

    I just saw when I tested the page and I changed
    from current_user_can(access_s2member_level4) to current_user_is(s2member_level4)
    that I couldn’t see the text for the screen as an admin

    also when you say to have no breaking lines between
    /s2IF and s2IF/ what would this look like?

    this is what I have at the moment:

    [s2If current_user_is(access_s2member_level1)]
    Home Page: [ <span style=”color: #ff0000;”>click here</span> ]
    Logout of Membership: [ <span style=”color: red;”>[logout_to_home text=”click here”]</span> ]
    [/s2If]

    can you show me how I would change it to eliminate any extra blank lines?

    just trying to see the best way to code this part as all levels will access
    this page and I want to take them back to their specific welcome/account page

    thank you – Joshua

    #521
    Joshua Shapiro
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4777

    Cristian – I put all the s2IF conditions together (eliminating the blank lines) – figured out what
    you were talking about and its working

    but I want to clarify that in Jason examples using [s2IF current_user_can (access_s2member_levelX)]
    this is for any level which is level X and greater so since our level 4 is free lifetime members – which is
    an admin I used “can” —

    thank you again –

    now I am assuming when I take my test trial member and upgrade him to a paid level,
    that s2member pro already sees he is a registered members and just changes his role
    to the level he pays for – is this correct? so that I know any people who first join as a trial
    member will be able to upgrade automatically by going through paypal

    thank you – Joshua

    #522

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4777

    Great! Glad you figured it out. 🙂

    when I take my test trial member and upgrade him to a paid level, that s2member pro already sees he is a registered members and just changes his role to the level he pays for – is this correct?

    If the person is logged in when he starts the upgrade process, his account will be referenced and the purchase will go towards it instead of a new account. Just make sure he’s logged in when he loads the page with the payment pro-form.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.