Wordpress plugin question 'text' widget

Discussion in 'Integration' started by superfunscience, Jul 7, 2008.

  1. superfunscience

    superfunscience New Member

    Joined:
    Jun 30, 2008
    Messages:
    4
    I believe I may have misunderstood the documentation on the AMember plugin.
    I am not asking about the wordpress login plugin.
    What is the way I can make a wordpress "text" widget only appear for a logged in member?
    I thought this was possible but now I am failing completely to find any documentation on it.

    :confused:

    Thank you in advance for any help you have for me.
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    I use a combination of this plugin:

    http://wordpress.org/extend/plugins/exec-php/

    and this code in your text widget:

    Code:
    <? php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    
    } else { // user is not logged-in 
    }
    ?>
    Now the only issue with this is that it will always display, at minimum, the title for the text widget.

    You could take a look at the code I have in my Amember sidebar widget and modify it for your own purposes:

    http://amember.com/forum/showthread.php?t=7476
  3. superfunscience

    superfunscience New Member

    Joined:
    Jun 30, 2008
    Messages:
    4
    Ah thanks, that looks like it will work.
    At least I can put "you must be logged in to view this content" into 'else'
  4. superfunscience

    superfunscience New Member

    Joined:
    Jun 30, 2008
    Messages:
    4
    hmmmm... doesn't seem to be working right
    not sure what's going on.
    even directly copied code is giving me:

    Parse error: syntax error, unexpected T_IF in /home/content/(stuff)/html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 2

    and line 2 is the user check so... I don't have a clue.
    As far as I thought the syntax there was solid.
  5. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Sorry, made an assumption I probably should not have..

    Does your page have an existing session start?

    if not, you will also need to add that to your page template or to the text widget itself (be sure to only have one on the page)

    Code:
    <?php session_start(); ?>
    and here is sample code from the Amember manual to give you a more generic example:

    Code:
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "Hello $au[name_f] $au[name_l]!<br>";
    print "<a href='/amember/logout.php'>Logout</a>";
    } else { // user is not logged-in
    print "<form method=post action='/amember/login.php'>
    Username: <input type=text name=amember_login size=10><br>
    Password: <input type=password name=amember_pass size=10><br>
    <input type=submit value='Login'>
    </form>";
    }
    ?>

Share This Page