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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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