get user subscrption information

Discussion in 'Troubleshooting' started by chmava, Aug 28, 2013.

  1. dale_s

    dale_s Member

    Joined:
    Apr 12, 2013
    Messages:
    96
    I am attempting to expand on this.

    If I wanted to show some text if they have a product but redirect them somewhere else if they don't, would this be the proper usage of an else statement:

    PHP:
    <?php
    if ( am4_has_amember_subscriptions( array(21) ) )  {
    ?>
    <p>some text that will show here for 21</p>
    <?php
    }
    else {
    <
    META http-equiv="refresh" content="0;URL=https://www.mysite.com/page1/">
    ?>
    Thanks for any suggestions.
  2. robw

    robw CGI-Central Partner

    Joined:
    Dec 18, 2007
    Messages:
    287
    Hi Dale,

    Your code, as posted, has an error - it should look like this:

    PHP:
    <?php
    if ( am4_has_amember_subscriptions( array(21) ) )  {
    ?>
    <p>some text that will show here for 21</p>
    <?php
    }
    else {
    ?>
    <META http-equiv="refresh" content="0;URL=https://www.mysite.com/page1/">
    <?php
    // closes the else parenthesis
    ?>
    As an aside, the meta refresh should be in the <head></head> section of your page, whereas the text will generally want to be in the <body></body> section, so using this if/else is unlikely to be ideal...

    Instead, you'll probably want to use TWO separate if statements - one in the body:

    PHP:
    <?php
    if ( am4_has_amember_subscriptions(21)  {
    ?>
    <p>some text that will show here for 21</p>
    <?php
    }
    ?>
    and a negated one in the head like:

    PHP:
    <?php
    if ( !am4_has_amember_subscriptions(21) )  {
    ?>
    <META http-equiv="refresh" content="0;URL=https://www.mysite.com/page1/">
    <?php
    }
    ?>
    Or, if using Wordpress, simply use the plugin that aMember provides and protect the page that way to get the redirect.

    Cheers
    Rob
    caesar likes this.

Share This Page