• 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?

#1
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!
 

Attachments

AndyB

Well-known member
#2
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...

}
?>
 
#3
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 ''; }







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...

}
?>
 

AndyB

Well-known member
#4
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
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.

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.