1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Resoled: How can I show part of my PHP search results just to logged in members?

Discussion in 'XenForo Development Discussions' started by liv4spd, Sep 25, 2013.

  1. liv4spd

    liv4spd Member

    Enclosed is a PHP file that I linked to my webpage inside XenForo. It queries a SQL database and rendered the results in a table. My question is how could I make the last three rows of the rendered table show up only to logged in members?

    I found these on the internet, but do not seem to work:
    <xen:if is="{$visitor.user_id}">
    This content will show to logged in members
    </xen:if>"


    Your help is greatly appreciated!
     

    Attached Files:

  2. AndyB

    AndyB Well-Known Member

    You could check to see if there is a xf_user cookie set.

    PHP:

    <?php

    $bbuserid 
    $_COOKIE["xf_user"];
    $pos strpos($bbuserid',');
    $bbuserid substr($bbuserid,0,$pos);

    if (
    $bbuserid != '') {
        echo 
    '<tr>';
        echo 
    '<td style="width:63px; text-align:right; font-weight:bold; background-color:#FF9;">English: </td>';

        
    etc...

    }
    ?>
     
    liv4spd likes this.
  3. liv4spd

    liv4spd Member

    Thank you for the reply. I just tried it out.

    Unfortunately, it does not seem to work, and now I got the below extra thing in the search results.

    if ( != '') { echo ''; echo ''; echo ''; echo ''; }







     
  4. AndyB

    AndyB Well-Known Member

    Coding is tricky, one character out of place and it won't work.

    In post #1 you wrote "Enclosed is a PHP file that I linked to my webpage inside XenForo.". Could you elaborate a bit on this.
     
  5. liv4spd

    liv4spd Member

    I created a new node within XenForo, then use PHP call back to link to the PHP file that are stored in a sub folder of the library folder.

     
  6. liv4spd

    liv4spd Member

    Thanks to the big help from Andy, I was able to resolve this issue :D
     
    AndyB likes this.

Share This Page