member.php - How do I show some text for members who have a specific product?

Discussion in 'Templates customization' started by JamesAB, Oct 21, 2008.

  1. JamesAB

    JamesAB New Member

    Joined:
    Jan 16, 2005
    Messages:
    23
    On the members.php page we would like to show a block of text if the logged in member has a current subscription to product #9 OR has an expired subscription to product #9.

    People with no subscriptions or subscriptions that do not include product #9 should never see this block of text, but we would like to display an alternate block of text to them instead.

    Is this possible? What would I need to change to set this up?

    Thanks,
    James
  2. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    add this in member.html template where you want that block of text to appear:

    Code:
    {if ($smarty.session._amember_products AND (in_array(9, $smarty.session._amember_product_ids)) }
    
    your block of text
    
    {/if}
    that should do it...

    I'm pretty sure that doesn't check for active subscription, so it will be true whether they have active or expired subscription.

    If you wanted to add a check for active subscription I'd add this condition in the IF statement up there:

    Code:
    AND ($smarty.session._amember_user.status == 1)
  3. jazzedge

    jazzedge Member

    Joined:
    Aug 11, 2007
    Messages:
    54
    error in the code. should be...

    Code:
    {if ($smarty.session._amember_products AND (in_array(9, $smarty.session._amember_product_ids))) }
    
    your block of text
    
    {/if}

    needed one more ')'
  4. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    my bad... those brackets will get to ya...

    but yeah, that should do it.
  5. JamesAB

    JamesAB New Member

    Joined:
    Jan 16, 2005
    Messages:
    23
    Thanks for your help miso & jazzedge.

    Is it possible to add an "else" statement so everyone with an active or expired #9 subscription sees the first text and everyone else would see different text?

    In other words, all users would see one or the other text versions based on if they are subcription #9 members or not.

    Or would I need a second "if" statement to check if they are NOT #9 subscribers to show the second text?

    Thanks for your help,
    James
  6. JamesAB

    JamesAB New Member

    Joined:
    Jan 16, 2005
    Messages:
    23
    I'll answer my own question. Even I couldn't mess this up now. :eek:

    Code:
    {if ($smarty.session._amember_products AND (in_array(9, $smarty.session._amember_product_ids))) }
    your 1st block of text
    {else}
    your 2nd block of text
    {/if}
    That does the trick for me.

    Thanks again for your help getting started.

    -James
  7. JamesAB

    JamesAB New Member

    Joined:
    Jan 16, 2005
    Messages:
    23
    I got too excited, too soon. :eek:

    After doing some more testing, I realized that this code only works if the member has an active #9 subsciption.

    I need to show this same message to all active AND expired #9 members.

    Right now people with expired #9 subscriptions are not seeing the first message.

    Any ideas how I can make this work for both active AND expired members?

    Thanks again,
    James
  8. jazzedge

    jazzedge Member

    Joined:
    Aug 11, 2007
    Messages:
    54
    How about:

    Code:
    {if ($smarty.session._amember_products AND (in_array(9, $smarty.session._amember_product_ids))) }
    your 1st block of text
    {else}
    your 1st block of text
    your 2nd block of text
    {/if}
  9. JamesAB

    JamesAB New Member

    Joined:
    Jan 16, 2005
    Messages:
    23
    Thanks for the suggestion jazzedge, but that would show everybody the first block of text and some people would see both blocks.

    I need to show the first block of text only to existing AND expired members of product #9. Everyone else should never see the first block of text.

    I need to show the second block of text to everyone else. Existing AND expired members of product #9 should never see the second block of text.

    It must be possible. Any more ideas?

    Thanks for everyone's help.
    -James
  10. tttadmin

    tttadmin New Member

    Joined:
    Jun 6, 2009
    Messages:
    30
    Continuing

    I too would like to do this. I have been able to completely customize the content of members.php based on active subscriptions. My users always get a free 7 day trial. Currently, I display a generic message for any user that has no subscriptions at all. I would like to able to display specific messages for different types of expired subscriptions, such as, a free trial member who never ended up buying versus someone who bought a month then did not renew.

    Any ideas? Hopefully there is a way!

Share This Page