PHP code to protect content in wordpress template

Discussion in 'Setting-up protection' started by bennyuk1, Apr 19, 2018.

  1. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    200
    IHi,
    I need to protect certain content via php code in wordpress template file.

    easiest way would be to protect
    get_template_part('content', 'survey');

    eg
    Is there a good way to do this in php code, like using the shortcodes [am4show] ?

    I've used this in the past to show simple messages:-

    <?php
    echo do_shortcode('[am4show not_have="p30;" have="p37;" ]<p>show message here</p>
    [/am4show]');
    ?>

    but I want to have a simple if else in php code.

    Could I use something like this:-
    <?php
    if (Am_Lite::getInstance()->haveSubscriptions(array(1, 10))) {
    get_template_part('content', 'survey') ;
    } else {
    echo '<p>This content is for full members only.</p>';
    }
    ?>
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    You can use Am_Lite within WP templates if you install aMember plugin to WP.

Share This Page