Jump to content

Show content only for certain users


leeandrew

Recommended Posts

I want to show content on my site only to users that have over a certain number of points.

 

users earn points and are stored in cell `points`

 

I want to show content to users with over 50 points... currently i have it to show admins only with this code:

 

<?php 
  // If the user is an administrator, show the admin index.
  if($isAdmin) {
    require "hiddencontent/index.php";
  }
?>

 

How can i edit this to show only to users with over 50 points?

Link to comment
https://forums.phpfreaks.com/topic/95688-show-content-only-for-certain-users/
Share on other sites

I have added an else feature too.

So for anyone wanting to display something similar, the code is as follows...

 

<?php 
  // If the user is an administrator, show the admin index.
  if($User->points >= '50') {
    require "hiddencontent/index.php";
  }
else {
echo "
<p style='border:1px dashed red;background-color:white'>
You need at least <b>50 points</b> to unlock this section</b>
</p>
";
}

?>

 

If your user has 50 or more points in DB cell `points` they are shown the content from file 'hiddencontent/index.php', if they have less than 50 they are shown the else message.

 

Cheers for your help peranha!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.