leeandrew Posted March 11, 2008 Share Posted March 11, 2008 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 More sharing options...
peranha Posted March 11, 2008 Share Posted March 11, 2008 <?php // If the user is an administrator, show the admin index. if($points >= '50') { require "hiddencontent/index.php"; } ?> Set point number to the variable $points Link to comment https://forums.phpfreaks.com/topic/95688-show-content-only-for-certain-users/#findComment-489898 Share on other sites More sharing options...
leeandrew Posted March 11, 2008 Author Share Posted March 11, 2008 Thanks for your help! I changed it to this and now its working: <?php // If the user is an administrator, show the admin index. if($User->points >= '50') { require "hiddencontent/index.php"; } ?> Thanks Link to comment https://forums.phpfreaks.com/topic/95688-show-content-only-for-certain-users/#findComment-489908 Share on other sites More sharing options...
leeandrew Posted March 11, 2008 Author Share Posted March 11, 2008 How do i mark as solved? Link to comment https://forums.phpfreaks.com/topic/95688-show-content-only-for-certain-users/#findComment-489910 Share on other sites More sharing options...
peranha Posted March 11, 2008 Share Posted March 11, 2008 That feature hasnt been installed since the update. Link to comment https://forums.phpfreaks.com/topic/95688-show-content-only-for-certain-users/#findComment-489918 Share on other sites More sharing options...
leeandrew Posted March 11, 2008 Author Share Posted March 11, 2008 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 https://forums.phpfreaks.com/topic/95688-show-content-only-for-certain-users/#findComment-489925 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.