Hide/Show Content in PHP without Wordpress

Discussion in 'Setting-up protection' started by demo, Nov 23, 2012.

  1. demo

    demo New Member

    Joined:
    Nov 10, 2011
    Messages:
    6
    As far as I have seen in the forum and manual, amember pro v4, allows to hide or shows certain portion in a page using short codes when integrated with wordpress. But I would like to know if amember pro v4 can hide certain text without the need to integrate it with wordpress. I heard that Am_lite... must be put on top of the php script that is outside amember folder.For example, in URL " www.example.com/foo.php, the foo.php contains some lessons for members. But when the user not logged in, foo.php must show particular text or portion of content only. When the user logged in, the same foo.php must show full content but hide those text shown to non members. Is this possible with amember pro v4 without using wordpress integration? Thanks
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
  3. demo

    demo New Member

    Joined:
    Nov 10, 2011
    Messages:
    6
    Hello Mr. David
    Thank you for the link for protecting content /PHP scripts. It protects the whole page itself and redirects to login page. Once logged, the protected content will show. But I am asking for hidden text within a webpage and it must show only if logged in. Otherwise the other contents in the same page must be visible to non members. Is this possible in version 4? Please do let me know. Thanks David.
  4. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    Hi
    This is so simple to do, without wordpress, using plain simple PHP.

    Construct your page normally but leave out the text for both members and non members. At start of page include the line-
    PHP:
    <?php
    require_once '/home/xxxxx/public_html/membership/library/Am/Lite.php';
    ?>
    but remember to change the xxxxx to your details and 'membership' to directory containing aMember.

    Now simply include the following in body of page where you want the text to appear

    PHP:
    <?php
    if(Am_Lite::getInstance()->isLoggedIn() ){
    include(
    'memberspage.php')
    }else{
    include(
    'non-members.php')
    }
    You could, of course include everything on a single page by replacing the the above code with:
    PHP:
    if(Am_Lite::getInstance()->isLoggedIn() ){
    echo [
    text here for members]
    }else{
    echo [
    text here for non members]
    }
    Note above has not been tested so might need checking but the general idea most definitely will work how you are wanting.
  5. demo

    demo New Member

    Joined:
    Nov 10, 2011
    Messages:
    6
    Hi Thehpmc,
    Thank you very much for a valuable reply. Your php code ideas are really excellent. I will implement it. Thank you once again.
  6. blctech

    blctech New Member

    Joined:
    Mar 1, 2013
    Messages:
    11
    Hi David or thehpmc

    We have been using aMember 3 with Wordpress and are upgrading to aMember 4. In Am3 we controlled access to each individual WP post on the Front Page page by making a PHP call to the Amemeber database and seeing if they were a subscribing member. There may be say 10 posts on the Front page for viewing and if they were a subscribing member they would see the content of each post.

    If they were not a subscribing member they would only see the Post title and the content would only show a message telling them if they wanted to see the content of they post, they would have to subscribe.

    Would using short codes with AM 4 and WP allow us to do this fine grain protection with aMember 4. Do you have a recommendation? .

Share This Page